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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 526 |
527 def PostExecution(self): | 527 def PostExecution(self): |
528 perf = perf_control.PerfControl(self.device) | 528 perf = perf_control.PerfControl(self.device) |
529 perf.SetDefaultPerfMode() | 529 perf.SetDefaultPerfMode() |
530 self.device.RunShellCommand(["rm", "-rf", AndroidPlatform.DEVICE_DIR]) | 530 self.device.RunShellCommand(["rm", "-rf", AndroidPlatform.DEVICE_DIR]) |
531 | 531 |
532 def _SendCommand(self, cmd): | 532 def _SendCommand(self, cmd): |
533 logging.info("adb -s %s %s" % (str(self.device), cmd)) | 533 logging.info("adb -s %s %s" % (str(self.device), cmd)) |
534 return self.adb.SendCommand(cmd, timeout_time=60) | 534 return self.adb.SendCommand(cmd, timeout_time=60) |
535 | 535 |
536 def _PushFile(self, host_dir, file_name, target_rel="."): | 536 def _PushFile(self, host_dir, file_name, target_rel=".", |
| 537 skip_if_missing=False): |
537 file_on_host = os.path.join(host_dir, file_name) | 538 file_on_host = os.path.join(host_dir, file_name) |
538 file_on_device_tmp = os.path.join( | 539 file_on_device_tmp = os.path.join( |
539 AndroidPlatform.DEVICE_DIR, "_tmp_", file_name) | 540 AndroidPlatform.DEVICE_DIR, "_tmp_", file_name) |
540 file_on_device = os.path.join( | 541 file_on_device = os.path.join( |
541 AndroidPlatform.DEVICE_DIR, target_rel, file_name) | 542 AndroidPlatform.DEVICE_DIR, target_rel, file_name) |
542 folder_on_device = os.path.dirname(file_on_device) | 543 folder_on_device = os.path.dirname(file_on_device) |
543 | 544 |
| 545 # Only attempt to push files that exist. |
| 546 if not os.path.exists(file_on_host): |
| 547 if not skip_if_missing: |
| 548 logging.critical('Missing file on host: %s' % file_on_host) |
| 549 return |
| 550 |
544 # Only push files not yet pushed in one execution. | 551 # Only push files not yet pushed in one execution. |
545 if file_on_host in self.pushed: | 552 if file_on_host in self.pushed: |
546 return | 553 return |
547 else: | 554 else: |
548 self.pushed.add(file_on_host) | 555 self.pushed.add(file_on_host) |
549 | 556 |
550 # Work-around for "text file busy" errors. Push the files to a temporary | 557 # Work-around for "text file busy" errors. Push the files to a temporary |
551 # location and then copy them with a shell command. | 558 # location and then copy them with a shell command. |
552 output = self._SendCommand( | 559 output = self._SendCommand( |
553 "push %s %s" % (file_on_host, file_on_device_tmp)) | 560 "push %s %s" % (file_on_host, file_on_device_tmp)) |
554 # Success looks like this: "3035 KB/s (12512056 bytes in 4.025s)". | 561 # Success looks like this: "3035 KB/s (12512056 bytes in 4.025s)". |
555 # Errors look like this: "failed to copy ... ". | 562 # Errors look like this: "failed to copy ... ". |
556 if output and not re.search('^[0-9]', output.splitlines()[-1]): | 563 if output and not re.search('^[0-9]', output.splitlines()[-1]): |
557 logging.critical('PUSH FAILED: ' + output) | 564 logging.critical('PUSH FAILED: ' + output) |
558 self._SendCommand("shell mkdir -p %s" % folder_on_device) | 565 self._SendCommand("shell mkdir -p %s" % folder_on_device) |
559 self._SendCommand("shell cp %s %s" % (file_on_device_tmp, file_on_device)) | 566 self._SendCommand("shell cp %s %s" % (file_on_device_tmp, file_on_device)) |
560 | 567 |
561 def PreTests(self, node, path): | 568 def PreTests(self, node, path): |
562 suite_dir = os.path.abspath(os.path.dirname(path)) | 569 suite_dir = os.path.abspath(os.path.dirname(path)) |
563 if node.path: | 570 if node.path: |
564 bench_rel = os.path.normpath(os.path.join(*node.path)) | 571 bench_rel = os.path.normpath(os.path.join(*node.path)) |
565 bench_abs = os.path.join(suite_dir, bench_rel) | 572 bench_abs = os.path.join(suite_dir, bench_rel) |
566 else: | 573 else: |
567 bench_rel = "." | 574 bench_rel = "." |
568 bench_abs = suite_dir | 575 bench_abs = suite_dir |
569 | 576 |
570 self._PushFile(self.shell_dir, node.binary) | 577 self._PushFile(self.shell_dir, node.binary) |
| 578 |
| 579 # Push external startup data. Backwards compatible for revisions where |
| 580 # these files didn't exist. |
| 581 self._PushFile(self.shell_dir, "natives_blob.bin", skip_if_missing=True) |
| 582 self._PushFile(self.shell_dir, "snapshot_blob.bin", skip_if_missing=True) |
| 583 |
571 if isinstance(node, Runnable): | 584 if isinstance(node, Runnable): |
572 self._PushFile(bench_abs, node.main, bench_rel) | 585 self._PushFile(bench_abs, node.main, bench_rel) |
573 for resource in node.resources: | 586 for resource in node.resources: |
574 self._PushFile(bench_abs, resource, bench_rel) | 587 self._PushFile(bench_abs, resource, bench_rel) |
575 | 588 |
576 def Run(self, runnable, count): | 589 def Run(self, runnable, count): |
577 cache = cache_control.CacheControl(self.device) | 590 cache = cache_control.CacheControl(self.device) |
578 cache.DropRamCaches() | 591 cache.DropRamCaches() |
579 binary_on_device = AndroidPlatform.DEVICE_DIR + runnable.binary | 592 binary_on_device = AndroidPlatform.DEVICE_DIR + runnable.binary |
580 cmd = [binary_on_device] + runnable.GetCommandFlags() | 593 cmd = [binary_on_device] + runnable.GetCommandFlags() |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 710 |
698 if options.json_test_results: | 711 if options.json_test_results: |
699 results.WriteToFile(options.json_test_results) | 712 results.WriteToFile(options.json_test_results) |
700 else: # pragma: no cover | 713 else: # pragma: no cover |
701 print results | 714 print results |
702 | 715 |
703 return min(1, len(results.errors)) | 716 return min(1, len(results.errors)) |
704 | 717 |
705 if __name__ == "__main__": # pragma: no cover | 718 if __name__ == "__main__": # pragma: no cover |
706 sys.exit(Main(sys.argv[1:])) | 719 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |