OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Performance runner for d8. | 7 Performance runner for d8. |
8 | 8 |
9 Call e.g. with tools/run-perf.py --arch ia32 some_suite.json | 9 Call e.g. with tools/run-perf.py --arch ia32 some_suite.json |
10 | 10 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 yield node | 457 yield node |
458 elif isinstance(node, Node): | 458 elif isinstance(node, Node): |
459 for child in node._children: | 459 for child in node._children: |
460 for result in FlattenRunnables(child, node_cb): | 460 for result in FlattenRunnables(child, node_cb): |
461 yield result | 461 yield result |
462 else: # pragma: no cover | 462 else: # pragma: no cover |
463 raise Exception("Invalid suite configuration.") | 463 raise Exception("Invalid suite configuration.") |
464 | 464 |
465 | 465 |
466 class Platform(object): | 466 class Platform(object): |
| 467 def __init__(self, options): |
| 468 self.shell_dir = options.shell_dir |
| 469 self.extra_flags = options.extra_flags.split() |
| 470 |
467 @staticmethod | 471 @staticmethod |
468 def GetPlatform(options): | 472 def GetPlatform(options): |
469 if options.arch.startswith("android"): | 473 if options.arch.startswith("android"): |
470 return AndroidPlatform(options) | 474 return AndroidPlatform(options) |
471 else: | 475 else: |
472 return DesktopPlatform(options) | 476 return DesktopPlatform(options) |
473 | 477 |
474 | 478 |
475 class DesktopPlatform(Platform): | 479 class DesktopPlatform(Platform): |
476 def __init__(self, options): | 480 def __init__(self, options): |
477 self.shell_dir = options.shell_dir | 481 super(DesktopPlatform, self).__init__(options) |
478 self.extra_flags = options.extra_flags.split() | |
479 | 482 |
480 def PreExecution(self): | 483 def PreExecution(self): |
481 pass | 484 pass |
482 | 485 |
483 def PostExecution(self): | 486 def PostExecution(self): |
484 pass | 487 pass |
485 | 488 |
486 def PreTests(self, node, path): | 489 def PreTests(self, node, path): |
487 if isinstance(node, Runnable): | 490 if isinstance(node, Runnable): |
488 node.ChangeCWD(path) | 491 node.ChangeCWD(path) |
(...skipping 16 matching lines...) Expand all Loading... |
505 print output.stderr | 508 print output.stderr |
506 if output.timed_out: | 509 if output.timed_out: |
507 print ">>> Test timed out after %ss." % runnable.timeout | 510 print ">>> Test timed out after %ss." % runnable.timeout |
508 return output.stdout | 511 return output.stdout |
509 | 512 |
510 | 513 |
511 class AndroidPlatform(Platform): # pragma: no cover | 514 class AndroidPlatform(Platform): # pragma: no cover |
512 DEVICE_DIR = "/data/local/tmp/v8/" | 515 DEVICE_DIR = "/data/local/tmp/v8/" |
513 | 516 |
514 def __init__(self, options): | 517 def __init__(self, options): |
515 self.shell_dir = options.shell_dir | 518 super(AndroidPlatform, self).__init__(options) |
516 self.extra_flags = options.extra_flags.split() | |
517 LoadAndroidBuildTools(options.android_build_tools) | 519 LoadAndroidBuildTools(options.android_build_tools) |
518 | 520 |
519 if not options.device: | 521 if not options.device: |
520 # Detect attached device if not specified. | 522 # Detect attached device if not specified. |
521 devices = pylib.android_commands.GetAttachedDevices( | 523 devices = pylib.android_commands.GetAttachedDevices( |
522 hardware=True, emulator=False, offline=False) | 524 hardware=True, emulator=False, offline=False) |
523 assert devices and len(devices) == 1, ( | 525 assert devices and len(devices) == 1, ( |
524 "None or multiple devices detected. Please specify the device on " | 526 "None or multiple devices detected. Please specify the device on " |
525 "the command-line with --device") | 527 "the command-line with --device") |
526 options.device = devices[0] | 528 options.device = devices[0] |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 726 |
725 if options.json_test_results: | 727 if options.json_test_results: |
726 results.WriteToFile(options.json_test_results) | 728 results.WriteToFile(options.json_test_results) |
727 else: # pragma: no cover | 729 else: # pragma: no cover |
728 print results | 730 print results |
729 | 731 |
730 return min(1, len(results.errors)) | 732 return min(1, len(results.errors)) |
731 | 733 |
732 if __name__ == "__main__": # pragma: no cover | 734 if __name__ == "__main__": # pragma: no cover |
733 sys.exit(Main(sys.argv[1:])) | 735 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |