Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1127)

Side by Side Diff: tools/testrunner/local/execution.py

Issue 1174923002: [test] Use generator to accelerate test runner startup. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2012 the V8 project authors. All rights reserved. 1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 self.indicator.Starting() 207 self.indicator.Starting()
208 self._RunInternal(jobs) 208 self._RunInternal(jobs)
209 self.indicator.Done() 209 self.indicator.Done()
210 if self.failed or self.remaining: 210 if self.failed or self.remaining:
211 return 1 211 return 1
212 return 0 212 return 0
213 213
214 def _RunInternal(self, jobs): 214 def _RunInternal(self, jobs):
215 pool = Pool(jobs) 215 pool = Pool(jobs)
216 test_map = {} 216 test_map = {}
217 # TODO(machenbach): Instead of filling the queue completely before 217 queued_exception = [None]
218 # pool.imap_unordered, make this a generator that already starts testing 218 def gen_tests():
219 # while the queue is filled. 219 for test in self.tests:
220 queue = [] 220 assert test.id >= 0
221 queued_exception = None 221 test_map[test.id] = test
222 for test in self.tests: 222 try:
223 assert test.id >= 0 223 yield [self._GetJob(test)]
224 test_map[test.id] = test 224 except Exception, e:
225 try: 225 # If this failed, save the exception and re-raise it later (after
226 queue.append([self._GetJob(test)]) 226 # all other tests have had a chance to run).
227 except Exception, e: 227 queued_exception[0] = e
228 # If this failed, save the exception and re-raise it later (after 228 continue
229 # all other tests have had a chance to run).
230 queued_exception = e
231 continue
232 try: 229 try:
233 it = pool.imap_unordered(RunTest, queue) 230 it = pool.imap_unordered(RunTest, gen_tests())
234 for result in it: 231 for result in it:
235 if result.heartbeat: 232 if result.heartbeat:
236 self.indicator.Heartbeat() 233 self.indicator.Heartbeat()
237 continue 234 continue
238 test = test_map[result.value[0]] 235 test = test_map[result.value[0]]
239 if self.context.predictable: 236 if self.context.predictable:
240 update_perf = self._ProcessTestPredictable(test, result.value, pool) 237 update_perf = self._ProcessTestPredictable(test, result.value, pool)
241 else: 238 else:
242 update_perf = self._ProcessTestNormal(test, result.value, pool) 239 update_perf = self._ProcessTestNormal(test, result.value, pool)
243 if update_perf: 240 if update_perf:
244 self._RunPerfSafe(lambda: self.perfdata.UpdatePerfData(test)) 241 self._RunPerfSafe(lambda: self.perfdata.UpdatePerfData(test))
245 finally: 242 finally:
246 self._VerbosePrint("Closing process pool.") 243 self._VerbosePrint("Closing process pool.")
247 pool.terminate() 244 pool.terminate()
248 self._VerbosePrint("Closing database connection.") 245 self._VerbosePrint("Closing database connection.")
249 self._RunPerfSafe(lambda: self.perf_data_manager.close()) 246 self._RunPerfSafe(lambda: self.perf_data_manager.close())
250 if self.perf_failures: 247 if self.perf_failures:
251 # Nuke perf data in case of failures. This might not work on windows as 248 # Nuke perf data in case of failures. This might not work on windows as
252 # some files might still be open. 249 # some files might still be open.
253 print "Deleting perf test data due to db corruption." 250 print "Deleting perf test data due to db corruption."
254 shutil.rmtree(self.datapath) 251 shutil.rmtree(self.datapath)
255 if queued_exception: 252 if queued_exception[0]:
256 raise queued_exception 253 raise queued_exception[0]
257 254
258 # Make sure that any allocations were printed in predictable mode (if we 255 # Make sure that any allocations were printed in predictable mode (if we
259 # ran any tests). 256 # ran any tests).
260 assert ( 257 assert (
261 not self.total or 258 not self.total or
262 not self.context.predictable or 259 not self.context.predictable or
263 self.printed_allocations 260 self.printed_allocations
264 ) 261 )
265 262
266 def _VerbosePrint(self, text): 263 def _VerbosePrint(self, text):
(...skipping 15 matching lines...) Expand all
282 test.suite.GetFlagsForTestCase(test, self.context) + 279 test.suite.GetFlagsForTestCase(test, self.context) +
283 self.context.extra_flags) 280 self.context.extra_flags)
284 return cmd 281 return cmd
285 282
286 283
287 class BreakNowException(Exception): 284 class BreakNowException(Exception):
288 def __init__(self, value): 285 def __init__(self, value):
289 self.value = value 286 self.value = value
290 def __str__(self): 287 def __str__(self):
291 return repr(self.value) 288 return repr(self.value)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698