| 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 import time | |
| 14 | 13 |
| 15 | 14 |
| 16 GIT = 'git.bat' if os.name == 'nt' else 'git' | 15 GIT = 'git.bat' if os.name == 'nt' else 'git' |
| 17 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+)' |
| 18 | 17 |
| 19 | 18 |
| 20 def BenchArgs(data_file): | 19 def BenchArgs(data_file): |
| 21 """ Builds a list containing arguments to pass to bench. | 20 """ Builds a list containing arguments to pass to bench. |
| 22 | 21 |
| 23 data_file: filepath to store the log output | 22 data_file: filepath to store the log output |
| 24 """ | 23 """ |
| 25 return ['--timers', 'wcg', '--logFile', data_file] | 24 return ['--timers', 'wcg', '--logFile', data_file] |
| 26 | 25 |
| 27 | 26 |
| 28 def GetSvnRevision(commit_hash): | 27 def GetSvnRevision(commit_hash): |
| 29 # Run "git show" in a retry loop, because it occasionally fails. | 28 output = shell_utils.Bash([GIT, 'show', commit_hash], echo=False, |
| 30 for i in xrange(30): | 29 log_in_real_time=False) |
| 31 output = shell_utils.Bash([GIT, 'show', commit_hash], echo=False) | 30 results = re.findall(GIT_SVN_ID_MATCH_STR, output) |
| 32 if output: | 31 if results: |
| 33 results = re.findall(GIT_SVN_ID_MATCH_STR, output) | 32 return results[0] |
| 34 if results: | 33 else: |
| 35 return results[0] | 34 raise Exception('No git-svn-id found for %s\nOutput:\n%s' % (commit_hash, |
| 36 else: | 35 output)) |
| 37 print 'No git-svn-id found for %s\nOutput:\n%s' % (commit_hash, output) | |
| 38 else: | |
| 39 # Sleep for 1 second and hope the next iteration gives us output. | |
| 40 print 'No output from "git show", retrying.. #%s' % (i + 1) | |
| 41 time.sleep(1) | |
| 42 raise Exception('Unable to parse git-svn-id!') | |
| 43 | 36 |
| 44 | 37 |
| 45 class RunBench(BuildStep): | 38 class RunBench(BuildStep): |
| 46 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): | 39 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): |
| 47 super(RunBench, self).__init__(timeout=timeout, | 40 super(RunBench, self).__init__(timeout=timeout, |
| 48 no_output_timeout=no_output_timeout, | 41 no_output_timeout=no_output_timeout, |
| 49 **kwargs) | 42 **kwargs) |
| 50 | 43 |
| 51 def _BuildDataFile(self): | 44 def _BuildDataFile(self): |
| 52 return os.path.join(self._device_dirs.PerfDir(), | 45 return os.path.join(self._device_dirs.PerfDir(), |
| 53 'bench_r%s_data' % GetSvnRevision(self._got_revision)) | 46 'bench_r%s_data' % GetSvnRevision(self._got_revision)) |
| 54 | 47 |
| 55 def _Run(self): | 48 def _Run(self): |
| 56 args = [] | 49 args = [] |
| 57 if self._perf_data_dir: | 50 if self._perf_data_dir: |
| 58 args.extend(BenchArgs(self._BuildDataFile())) | 51 args.extend(BenchArgs(self._BuildDataFile())) |
| 59 if 'Nexus4' in self._builder_name: | 52 if 'Nexus4' in self._builder_name: |
| 60 args.extend(['--config', 'defaults', 'MSAA4']) | 53 args.extend(['--config', 'defaults', 'MSAA4']) |
| 61 self._flavor_utils.RunFlavoredCmd('bench', args + self._bench_args) | 54 self._flavor_utils.RunFlavoredCmd('bench', args + self._bench_args) |
| 62 | 55 |
| 63 | 56 |
| 64 if '__main__' == __name__: | 57 if '__main__' == __name__: |
| 65 sys.exit(BuildStep.RunBuildStep(RunBench)) | 58 sys.exit(BuildStep.RunBuildStep(RunBench)) |
| OLD | NEW |