| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium 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 """ Run the Skia benchmarking executable. """ | 6 """ Run the Skia benchmarking executable. """ |
| 7 | 7 |
| 8 from build_step import BuildStep | 8 from build_step import BuildStep |
| 9 from utils import shell_utils | 9 from utils import shell_utils |
| 10 import os | 10 import os |
| 11 import re | 11 import re |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 | 14 |
| 15 GIT = 'git.bat' if os.name == 'nt' else 'git' | 15 GIT = 'git.bat' if os.name == 'nt' else 'git' |
| 16 GIT_SVN_ID_MATCH_STR = 'git-svn-id: http://skia.googlecode.com/svn/trunk@(\d+)' | 16 GIT_SVN_ID_MATCH_STR = 'git-svn-id: http://skia.googlecode.com/svn/trunk@(\d+)' |
| 17 | 17 |
| 18 | 18 |
| 19 def BenchArgs(data_file): | 19 def BenchArgs(data_file): |
| 20 """ Builds a list containing arguments to pass to bench. | 20 """ Builds a list containing arguments to pass to bench. |
| 21 | 21 |
| 22 data_file: filepath to store the log output | 22 data_file: filepath to store the log output |
| 23 """ | 23 """ |
| 24 return ['--timers', 'wcg', '--logFile', data_file] | 24 return ['--timers', 'wcg', '--logFile', data_file] |
| 25 | 25 |
| 26 | 26 |
| 27 def GetSvnRevision(commit_hash): | |
| 28 output = shell_utils.Bash([GIT, 'show', '-s', commit_hash], | |
| 29 echo=False, log_in_real_time=False) | |
| 30 results = re.findall(GIT_SVN_ID_MATCH_STR, output) | |
| 31 if results: | |
| 32 return results[0] | |
| 33 else: | |
| 34 raise Exception('No git-svn-id found for %s\nOutput:\n%s' % (commit_hash, | |
| 35 output)) | |
| 36 | |
| 37 | |
| 38 class RunBench(BuildStep): | 27 class RunBench(BuildStep): |
| 39 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): | 28 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): |
| 40 super(RunBench, self).__init__(timeout=timeout, | 29 super(RunBench, self).__init__(timeout=timeout, |
| 41 no_output_timeout=no_output_timeout, | 30 no_output_timeout=no_output_timeout, |
| 42 **kwargs) | 31 **kwargs) |
| 43 | 32 |
| 44 def _BuildDataFile(self): | 33 def _BuildDataFile(self): |
| 45 return os.path.join(self._device_dirs.PerfDir(), | 34 return os.path.join(self._device_dirs.PerfDir(), |
| 46 'bench_r%s_data' % GetSvnRevision(self._got_revision)) | 35 'bench_%s_data' % self._got_revision) |
| 47 | 36 |
| 48 def _Run(self): | 37 def _Run(self): |
| 49 args = ['-i', self._device_dirs.ResourceDir()] | 38 args = ['-i', self._device_dirs.ResourceDir()] |
| 50 if self._perf_data_dir: | 39 if self._perf_data_dir: |
| 51 args.extend(BenchArgs(self._BuildDataFile())) | 40 args.extend(BenchArgs(self._BuildDataFile())) |
| 52 if 'Nexus4' in self._builder_name: | 41 if 'Nexus4' in self._builder_name: |
| 53 args.extend(['--config', 'defaults', 'MSAA4']) | 42 args.extend(['--config', 'defaults', 'MSAA4']) |
| 54 self._flavor_utils.RunFlavoredCmd('bench', args + self._bench_args) | 43 self._flavor_utils.RunFlavoredCmd('bench', args + self._bench_args) |
| 55 | 44 |
| 56 | 45 |
| 57 if '__main__' == __name__: | 46 if '__main__' == __name__: |
| 58 sys.exit(BuildStep.RunBuildStep(RunBench)) | 47 sys.exit(BuildStep.RunBuildStep(RunBench)) |
| OLD | NEW |