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

Side by Side Diff: tools/run_perf.py

Issue 1255183002: [test] Replace android_commands in v8 perf runner. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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 #!/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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 GENERIC_RESULTS_RE = re.compile(r"^RESULT ([^:]+): ([^=]+)= ([^ ]+) ([^ ]*)$") 120 GENERIC_RESULTS_RE = re.compile(r"^RESULT ([^:]+): ([^=]+)= ([^ ]+) ([^ ]*)$")
121 RESULT_STDDEV_RE = re.compile(r"^\{([^\}]+)\}$") 121 RESULT_STDDEV_RE = re.compile(r"^\{([^\}]+)\}$")
122 RESULT_LIST_RE = re.compile(r"^\[([^\]]+)\]$") 122 RESULT_LIST_RE = re.compile(r"^\[([^\]]+)\]$")
123 123
124 124
125 def LoadAndroidBuildTools(path): # pragma: no cover 125 def LoadAndroidBuildTools(path): # pragma: no cover
126 assert os.path.exists(path) 126 assert os.path.exists(path)
127 sys.path.insert(0, path) 127 sys.path.insert(0, path)
128 128
129 from pylib.device import adb_wrapper # pylint: disable=F0401
130 from pylib.device import device_errors # pylint: disable=F0401
129 from pylib.device import device_utils # pylint: disable=F0401 131 from pylib.device import device_utils # pylint: disable=F0401
130 from pylib.device import device_errors # pylint: disable=F0401
131 from pylib.perf import cache_control # pylint: disable=F0401 132 from pylib.perf import cache_control # pylint: disable=F0401
132 from pylib.perf import perf_control # pylint: disable=F0401 133 from pylib.perf import perf_control # pylint: disable=F0401
133 import pylib.android_commands # pylint: disable=F0401 134 global adb_wrapper
134 global cache_control 135 global cache_control
135 global device_errors 136 global device_errors
136 global device_utils 137 global device_utils
137 global perf_control 138 global perf_control
138 global pylib
139 139
140 140
141 def GeometricMean(values): 141 def GeometricMean(values):
142 """Returns the geometric mean of a list of values. 142 """Returns the geometric mean of a list of values.
143 143
144 The mean is calculated using log to avoid overflow. 144 The mean is calculated using log to avoid overflow.
145 """ 145 """
146 values = map(float, values) 146 values = map(float, values)
147 return str(math.exp(sum(map(math.log, values)) / len(values))) 147 return str(math.exp(sum(map(math.log, values)) / len(values)))
148 148
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 645
646 class AndroidPlatform(Platform): # pragma: no cover 646 class AndroidPlatform(Platform): # pragma: no cover
647 DEVICE_DIR = "/data/local/tmp/v8/" 647 DEVICE_DIR = "/data/local/tmp/v8/"
648 648
649 def __init__(self, options): 649 def __init__(self, options):
650 super(AndroidPlatform, self).__init__(options) 650 super(AndroidPlatform, self).__init__(options)
651 LoadAndroidBuildTools(options.android_build_tools) 651 LoadAndroidBuildTools(options.android_build_tools)
652 652
653 if not options.device: 653 if not options.device:
654 # Detect attached device if not specified. 654 # Detect attached device if not specified.
655 devices = pylib.android_commands.GetAttachedDevices( 655 devices = adb_wrapper.AdbWrapper.Devices()
656 hardware=True, emulator=False, offline=False)
657 assert devices and len(devices) == 1, ( 656 assert devices and len(devices) == 1, (
658 "None or multiple devices detected. Please specify the device on " 657 "None or multiple devices detected. Please specify the device on "
659 "the command-line with --device") 658 "the command-line with --device")
660 options.device = devices[0] 659 options.device = str(devices[0])
661 adb_wrapper = pylib.android_commands.AndroidCommands(options.device) 660 self.adb_wrapper = adb_wrapper.AdbWrapper(options.device)
662 self.device = device_utils.DeviceUtils(adb_wrapper) 661 self.device = device_utils.DeviceUtils(self.adb_wrapper)
663 self.adb = adb_wrapper.Adb()
664 662
665 def PreExecution(self): 663 def PreExecution(self):
666 perf = perf_control.PerfControl(self.device) 664 perf = perf_control.PerfControl(self.device)
667 perf.SetHighPerfMode() 665 perf.SetHighPerfMode()
668 666
669 # Remember what we have already pushed to the device. 667 # Remember what we have already pushed to the device.
670 self.pushed = set() 668 self.pushed = set()
671 669
672 def PostExecution(self): 670 def PostExecution(self):
673 perf = perf_control.PerfControl(self.device) 671 perf = perf_control.PerfControl(self.device)
674 perf.SetDefaultPerfMode() 672 perf.SetDefaultPerfMode()
675 self.device.RunShellCommand(["rm", "-rf", AndroidPlatform.DEVICE_DIR]) 673 self.device.RunShellCommand(["rm", "-rf", AndroidPlatform.DEVICE_DIR])
676 674
677 def _SendCommand(self, cmd):
678 logging.info("adb -s %s %s" % (str(self.device), cmd))
679 return self.adb.SendCommand(cmd, timeout_time=60)
680
681 def _PushFile(self, host_dir, file_name, target_rel=".", 675 def _PushFile(self, host_dir, file_name, target_rel=".",
682 skip_if_missing=False): 676 skip_if_missing=False):
683 file_on_host = os.path.join(host_dir, file_name) 677 file_on_host = os.path.join(host_dir, file_name)
684 file_on_device_tmp = os.path.join( 678 file_on_device_tmp = os.path.join(
685 AndroidPlatform.DEVICE_DIR, "_tmp_", file_name) 679 AndroidPlatform.DEVICE_DIR, "_tmp_", file_name)
686 file_on_device = os.path.join( 680 file_on_device = os.path.join(
687 AndroidPlatform.DEVICE_DIR, target_rel, file_name) 681 AndroidPlatform.DEVICE_DIR, target_rel, file_name)
688 folder_on_device = os.path.dirname(file_on_device) 682 folder_on_device = os.path.dirname(file_on_device)
689 683
690 # Only attempt to push files that exist. 684 # Only attempt to push files that exist.
691 if not os.path.exists(file_on_host): 685 if not os.path.exists(file_on_host):
692 if not skip_if_missing: 686 if not skip_if_missing:
693 logging.critical('Missing file on host: %s' % file_on_host) 687 logging.critical('Missing file on host: %s' % file_on_host)
694 return 688 return
695 689
696 # Only push files not yet pushed in one execution. 690 # Only push files not yet pushed in one execution.
697 if file_on_host in self.pushed: 691 if file_on_host in self.pushed:
698 return 692 return
699 else: 693 else:
700 self.pushed.add(file_on_host) 694 self.pushed.add(file_on_host)
701 695
702 # Work-around for "text file busy" errors. Push the files to a temporary 696 # Work-around for "text file busy" errors. Push the files to a temporary
703 # location and then copy them with a shell command. 697 # location and then copy them with a shell command.
704 output = self._SendCommand( 698 output = self.adb_wrapper.Push(file_on_host, file_on_device_tmp)
705 "push %s %s" % (file_on_host, file_on_device_tmp))
706 # Success looks like this: "3035 KB/s (12512056 bytes in 4.025s)". 699 # Success looks like this: "3035 KB/s (12512056 bytes in 4.025s)".
707 # Errors look like this: "failed to copy ... ". 700 # Errors look like this: "failed to copy ... ".
708 if output and not re.search('^[0-9]', output.splitlines()[-1]): 701 if output and not re.search('^[0-9]', output.splitlines()[-1]):
709 logging.critical('PUSH FAILED: ' + output) 702 logging.critical('PUSH FAILED: ' + output)
710 self._SendCommand("shell mkdir -p %s" % folder_on_device) 703 self.adb_wrapper.Shell("mkdir -p %s" % folder_on_device)
711 self._SendCommand("shell cp %s %s" % (file_on_device_tmp, file_on_device)) 704 self.adb_wrapper.Shell("cp %s %s" % (file_on_device_tmp, file_on_device))
712 705
713 def _PushExecutable(self, shell_dir, target_dir, binary): 706 def _PushExecutable(self, shell_dir, target_dir, binary):
714 self._PushFile(shell_dir, binary, target_dir) 707 self._PushFile(shell_dir, binary, target_dir)
715 708
716 # Push external startup data. Backwards compatible for revisions where 709 # Push external startup data. Backwards compatible for revisions where
717 # these files didn't exist. 710 # these files didn't exist.
718 self._PushFile( 711 self._PushFile(
719 shell_dir, 712 shell_dir,
720 "natives_blob.bin", 713 "natives_blob.bin",
721 target_dir, 714 target_dir,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 891
899 if options.json_test_results_no_patch: 892 if options.json_test_results_no_patch:
900 results_no_patch.WriteToFile(options.json_test_results_no_patch) 893 results_no_patch.WriteToFile(options.json_test_results_no_patch)
901 else: # pragma: no cover 894 else: # pragma: no cover
902 print results_no_patch 895 print results_no_patch
903 896
904 return min(1, len(results.errors)) 897 return min(1, len(results.errors))
905 898
906 if __name__ == "__main__": # pragma: no cover 899 if __name__ == "__main__": # pragma: no cover
907 sys.exit(Main(sys.argv[1:])) 900 sys.exit(Main(sys.argv[1:]))
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