From: Jouni Malinen Date: Thu, 27 Nov 2014 18:08:15 +0000 (+0200) Subject: tests: Optimize run-tests.py --prefill-tests startup time X-Git-Tag: hostap_2_4~1010 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9363f5e065960056582367b715d3e19f4b7c4a65;p=thirdparty%2Fhostap.git tests: Optimize run-tests.py --prefill-tests startup time 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 --- diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 1d0746250..538b9ac5e 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -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('/')