summaryrefslogtreecommitdiff
path: root/regtest
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2014-10-26 11:21:23 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2014-10-26 11:33:38 +0100
commit68e58ec5465efc289d85ae104941db92450a3168 (patch)
tree5517ab69727d133b04ba6a7e9681c70f589c8e68 /regtest
parent7c21b95852e891060cd2e276949acf0945306ab7 (diff)
regtest: Limit the number of worker threads to the number of documents to test
We are always spawning all the threads even if the documents to test is less than the worker threads. Also optimize the case of running only one test to not spwn any thread.
Diffstat (limited to 'regtest')
-rw-r--r--regtest/TestRun.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/regtest/TestRun.py b/regtest/TestRun.py
index 7a2f5dfd..25319110 100644
--- a/regtest/TestRun.py
+++ b/regtest/TestRun.py
@@ -199,22 +199,31 @@ class TestRun:
backends = self._get_backends()
self._total_tests = total_docs * len(backends)
+ if total_docs == 1:
+ n_workers = 0
+ else:
+ n_workers = min(self.config.threads, total_docs)
+
self.printer.printout_ln('Found %d documents' % (total_docs))
self.printer.printout_ln('Backends: %s' % ', '.join([backend.get_name() for backend in backends]))
- self.printer.printout_ln('Process %d using %d worker threads' % (os.getpid(), self.config.threads))
+ self.printer.printout_ln('Process %d using %d worker threads' % (os.getpid(), n_workers))
self.printer.printout_ln()
- self.printer.printout('Spawning %d workers...' % (self.config.threads))
+ if n_workers > 0:
+ self.printer.printout('Spawning %d workers...' % (self.config.threads))
- for n_thread in range(self.config.threads):
- thread = Thread(target=self._worker_thread)
- thread.daemon = True
- thread.start()
+ for n_thread in range(n_workers):
+ thread = Thread(target=self._worker_thread)
+ thread.daemon = True
+ thread.start()
- for doc in docs:
- self._queue.put(doc)
+ for doc in docs:
+ self._queue.put(doc)
- self._queue.join()
+ self._queue.join()
+ else:
+ for doc in docs:
+ self.run_test(doc)
return int(self._n_passed != self._n_run)