]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Optimize run-tests.py --prefill-tests startup time
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 27 Nov 2014 18:08:15 +0000 (20:08 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 27 Nov 2014 18:08:15 +0000 (20:08 +0200)
It took significant part of the startup latency to prefill the database
with test cases due to the SQL COMMIT operation between each added row.
Move COMMIT to outside the loop to speed startup significantly.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
tests/hwsim/run-tests.py

index 1d07462509cc127d3cbe92b8e1be03a467946c63..538b9ac5e6199eef0e20bcada9f92d8daa62614a 100755 (executable)
@@ -76,7 +76,8 @@ def add_log_file(conn, test, run, type, path):
         print "sqlite: " + str(e)
         print "sql: %r" % (params, )
 
-def report(conn, prefill, build, commit, run, test, result, duration, logdir):
+def report(conn, prefill, build, commit, run, test, result, duration, logdir,
+           sql_commit=True):
     if conn:
         if not build:
             build = ''
@@ -88,7 +89,8 @@ def report(conn, prefill, build, commit, run, test, result, duration, logdir):
         params = (test, result, run, time.time(), duration, build, commit)
         try:
             conn.execute(sql, params)
-            conn.commit()
+            if sql_commit:
+                conn.commit()
         except Exception, e:
             print "sqlite: " + str(e)
             print "sql: %r" % (params, )
@@ -329,7 +331,8 @@ def main():
         for t in tests_to_run:
             name = t.__name__.replace('test_', '', 1)
             report(conn, False, args.build, args.commit, run, name, 'NOTRUN', 0,
-                   args.logdir)
+                   args.logdir, sql_commit=False)
+        conn.commit()
 
     if args.split:
         vals = args.split.split('/')