[test] Use generator to accelerate test runner startup.

This saves >1s for mjsunit and >10s for test262.

Review URL: https://codereview.chromium.org/1174923002

Cr-Commit-Position: refs/heads/master@{#28904}
This commit is contained in:
machenbach 2015-06-10 04:15:12 -07:00 committed by Commit bot
parent f8fe5c6bcf
commit 816b5b1761

View File

@ -219,23 +219,20 @@ class Runner(object):
def _RunInternal(self, jobs): def _RunInternal(self, jobs):
pool = Pool(jobs) pool = Pool(jobs)
test_map = {} test_map = {}
# TODO(machenbach): Instead of filling the queue completely before queued_exception = [None]
# pool.imap_unordered, make this a generator that already starts testing def gen_tests():
# while the queue is filled. for test in self.tests:
queue = [] assert test.id >= 0
queued_exception = None test_map[test.id] = test
for test in self.tests: try:
assert test.id >= 0 yield [self._GetJob(test)]
test_map[test.id] = test except Exception, e:
try: # If this failed, save the exception and re-raise it later (after
queue.append([self._GetJob(test)]) # all other tests have had a chance to run).
except Exception, e: queued_exception[0] = e
# If this failed, save the exception and re-raise it later (after continue
# all other tests have had a chance to run).
queued_exception = e
continue
try: try:
it = pool.imap_unordered(RunTest, queue) it = pool.imap_unordered(RunTest, gen_tests())
for result in it: for result in it:
if result.heartbeat: if result.heartbeat:
self.indicator.Heartbeat() self.indicator.Heartbeat()
@ -257,8 +254,8 @@ class Runner(object):
# some files might still be open. # some files might still be open.
print "Deleting perf test data due to db corruption." print "Deleting perf test data due to db corruption."
shutil.rmtree(self.datapath) shutil.rmtree(self.datapath)
if queued_exception: if queued_exception[0]:
raise queued_exception raise queued_exception[0]
# Make sure that any allocations were printed in predictable mode (if we # Make sure that any allocations were printed in predictable mode (if we
# ran any tests). # ran any tests).