Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """ Check for regressions in bench data. """ | 6 """ Check for regressions in bench data. """ |
| 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 | 10 |
| 11 import builder_name_schema | 11 import builder_name_schema |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 import urllib2 | |
| 15 | |
| 16 # URL prefix for getting bench expectations from skia-autogen svn repo. | |
| 17 AUTOGEN_BENCH_EXPECTATIONS_URL_PREFIX = ('http://skia-autogen.googlecode.com/' | |
| 18 'svn/bench/') | |
| 14 | 19 |
| 15 | 20 |
| 16 class CheckForRegressions(BuildStep): | 21 class CheckForRegressions(BuildStep): |
| 17 def __init__(self, timeout=600, no_output_timeout=600, **kwargs): | 22 def __init__(self, timeout=600, no_output_timeout=600, **kwargs): |
| 18 super(CheckForRegressions, self).__init__( | 23 super(CheckForRegressions, self).__init__( |
| 19 timeout=timeout, | 24 timeout=timeout, |
| 20 no_output_timeout=no_output_timeout, | 25 no_output_timeout=no_output_timeout, |
| 21 **kwargs) | 26 **kwargs) |
| 22 | 27 |
| 23 def _RunInternal(self, representation): | 28 def _RunInternal(self, representation): |
| 29 # Reads expectations from skia-autogen svn repo. | |
| 30 http_response = None | |
| 31 expectations_filename = ('bench_expectations_' + | |
| 32 builder_name_schema.GetWaterfallBot(self.builder_name) + '.txt') | |
| 33 url = AUTOGEN_BENCH_EXPECTATIONS_URL_PREFIX + expectations_filename | |
| 34 try: | |
| 35 http_response = urllib2.urlopen(url) | |
| 36 except urllib2.HTTPError, e: | |
| 37 if e.code == 404: | |
| 38 print 'Skip due to missing expectations: %s' % url | |
|
borenet
2014/03/13 20:45:37
You never check again to see whether http_response
benchen
2014/03/14 01:41:10
I must've deleted the line by mistake..
On 2014/03
| |
| 39 else: | |
| 40 raise Exception('HTTPError while reading expectations: %s' % e.code) | |
| 41 except urllib2.URLError, e: | |
| 42 raise Exception('URLError while reading expectations: %s' % e.reason) | |
|
borenet
2014/03/13 20:45:37
I would very strongly prefer to perform a source c
benchen
2014/03/14 01:41:10
I think svn cat is a good idea. Switched to using
| |
| 43 | |
| 24 path_to_check_bench_regressions = os.path.join('bench', | 44 path_to_check_bench_regressions = os.path.join('bench', |
| 25 'check_bench_regressions.py') | 45 'check_bench_regressions.py') |
| 26 # TODO(borenet): We should move these expectations into expectations/bench. | 46 |
| 47 # Writes the expectations from svn repo to the local file. | |
| 27 path_to_bench_expectations = os.path.join( | 48 path_to_bench_expectations = os.path.join( |
| 28 'bench', | 49 self._perf_range_input_dir, expectations_filename) |
| 29 'bench_expectations_%s.txt' % builder_name_schema.GetWaterfallBot( | 50 if os.path.exists(self._perf_range_input_dir): |
| 30 self._builder_name)) | 51 os.remove(path_to_bench_expectations) |
| 31 if not os.path.isfile(path_to_bench_expectations): | 52 else: |
| 32 print 'Skip due to missing expectations: %s' % path_to_bench_expectations | 53 os.makedirs(self._perf_range_input_dir) |
|
borenet
2014/03/13 20:45:37
Won't the below write replace the file if it alrea
benchen
2014/03/14 01:41:10
oh I wasn't sure about it. Done.
| |
| 33 return | 54 file_handle = open(path_to_bench_expectations, 'w') |
| 55 file_handle.write(http_response.read()) | |
| 56 file_handle.close() | |
|
borenet
2014/03/13 20:45:37
I'd think the "with" syntax is cleaner:
with open
benchen
2014/03/14 01:41:10
Done.
| |
| 57 | |
| 34 cmd = ['python', path_to_check_bench_regressions, | 58 cmd = ['python', path_to_check_bench_regressions, |
| 35 '-a', representation, | 59 '-a', representation, |
| 36 '-b', self._builder_name, | 60 '-b', self._builder_name, |
| 37 '-d', self._perf_data_dir, | 61 '-d', self._perf_data_dir, |
| 38 '-e', path_to_bench_expectations, | 62 '-e', path_to_bench_expectations, |
| 39 '-r', self._got_revision, | 63 '-r', self._got_revision, |
| 40 ] | 64 ] |
| 41 | 65 |
| 42 shell_utils.run(cmd) | 66 shell_utils.run(cmd) |
| 43 | 67 |
| 44 def _Run(self): | 68 def _Run(self): |
| 45 if self._perf_data_dir: | 69 if self._perf_data_dir: |
| 46 self._RunInternal('25th') | 70 self._RunInternal('25th') |
| 47 | 71 |
| 48 | 72 |
| 49 if '__main__' == __name__: | 73 if '__main__' == __name__: |
| 50 sys.exit(BuildStep.RunBuildStep(CheckForRegressions)) | 74 sys.exit(BuildStep.RunBuildStep(CheckForRegressions)) |
| OLD | NEW |