| OLD | NEW |
| 1 # Copyright (C) 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2012 Google Inc. All rights reserved. |
| 2 # Copyright (C) 2012 Zoltan Horvath, Adobe Systems Incorporated. All rights rese
rved. | 2 # Copyright (C) 2012 Zoltan Horvath, Adobe Systems Incorporated. All rights rese
rved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 stdev = math.sqrt(square_sum / (len(sorted_values) - 1)) if len(sorted_v
alues) > 1 else 0 | 156 stdev = math.sqrt(square_sum / (len(sorted_values) - 1)) if len(sorted_v
alues) > 1 else 0 |
| 157 | 157 |
| 158 _log.info('RESULT %s= %s %s' % (test_name, mean, unit)) | 158 _log.info('RESULT %s= %s %s' % (test_name, mean, unit)) |
| 159 _log.info('median= %s %s, stdev= %s %s, min= %s %s, max= %s %s' % | 159 _log.info('median= %s %s, stdev= %s %s, min= %s %s, max= %s %s' % |
| 160 (median, unit, stdev, unit, sorted_values[0], unit, sorted_values[-1
], unit)) | 160 (median, unit, stdev, unit, sorted_values[0], unit, sorted_values[-1
], unit)) |
| 161 | 161 |
| 162 _description_regex = re.compile(r'^Description: (?P<description>.*)$', re.IG
NORECASE) | 162 _description_regex = re.compile(r'^Description: (?P<description>.*)$', re.IG
NORECASE) |
| 163 _metrics_regex = re.compile(r'^(?P<metric>Time|Malloc|JS Heap):') | 163 _metrics_regex = re.compile(r'^(?P<metric>Time|Malloc|JS Heap):') |
| 164 _statistics_keys = ['avg', 'median', 'stdev', 'min', 'max', 'unit', 'values'
] | 164 _statistics_keys = ['avg', 'median', 'stdev', 'min', 'max', 'unit', 'values'
] |
| 165 _score_regex = re.compile(r'^(?P<key>' + r'|'.join(_statistics_keys) + r')\s
+(?P<value>([0-9\.]+(,\s+)?)+)\s*(?P<unit>.*)') | 165 _score_regex = re.compile(r'^(?P<key>' + r'|'.join(_statistics_keys) + r')\s
+(?P<value>([0-9\.]+(,\s+)?)+)\s*(?P<unit>.*)') |
| 166 _console_regex = re.compile(r'^CONSOLE MESSAGE:') |
| 166 | 167 |
| 167 def _run_with_driver(self, driver, time_out_ms): | 168 def _run_with_driver(self, driver, time_out_ms): |
| 168 output = self.run_single(driver, self.test_path(), time_out_ms) | 169 output = self.run_single(driver, self.test_path(), time_out_ms) |
| 169 self._filter_output(output) | 170 self._filter_output(output) |
| 170 if self.run_failed(output): | 171 if self.run_failed(output): |
| 171 return False | 172 return False |
| 172 | 173 |
| 173 current_metric = None | 174 current_metric = None |
| 174 for line in re.split('\n', output.text): | 175 for line in re.split('\n', output.text): |
| 175 description_match = self._description_regex.match(line) | 176 description_match = self._description_regex.match(line) |
| 176 metric_match = self._metrics_regex.match(line) | 177 metric_match = self._metrics_regex.match(line) |
| 177 score = self._score_regex.match(line) | 178 score = self._score_regex.match(line) |
| 179 console_match = self._console_regex.match(line) |
| 178 | 180 |
| 179 if description_match: | 181 if description_match: |
| 180 self._description = description_match.group('description') | 182 self._description = description_match.group('description') |
| 181 elif metric_match: | 183 elif metric_match: |
| 182 current_metric = metric_match.group('metric').replace(' ', '') | 184 current_metric = metric_match.group('metric').replace(' ', '') |
| 183 elif score: | 185 elif score: |
| 184 if score.group('key') != 'values': | 186 if score.group('key') != 'values': |
| 185 continue | 187 continue |
| 186 | 188 |
| 187 metric = self._ensure_metrics(current_metric, score.group('unit'
)) | 189 metric = self._ensure_metrics(current_metric, score.group('unit'
)) |
| 188 metric.append_group(map(lambda value: float(value), score.group(
'value').split(', '))) | 190 metric.append_group(map(lambda value: float(value), score.group(
'value').split(', '))) |
| 191 elif console_match: |
| 192 # Ignore console messages such as deprecation warnings. |
| 193 continue |
| 189 else: | 194 else: |
| 190 _log.error('ERROR: ' + line) | 195 _log.error('ERROR: ' + line) |
| 191 return False | 196 return False |
| 192 | 197 |
| 193 return True | 198 return True |
| 194 | 199 |
| 195 def _ensure_metrics(self, metric_name, unit=None): | 200 def _ensure_metrics(self, metric_name, unit=None): |
| 196 if metric_name not in self._metrics: | 201 if metric_name not in self._metrics: |
| 197 self._metrics[metric_name] = PerfTestMetric(metric_name, unit) | 202 self._metrics[metric_name] = PerfTestMetric(metric_name, unit) |
| 198 self._ordered_metrics_name.append(metric_name) | 203 self._ordered_metrics_name.append(metric_name) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 (re.compile(r'^Dromaeo/'), SingleProcessPerfTest), | 308 (re.compile(r'^Dromaeo/'), SingleProcessPerfTest), |
| 304 (re.compile(r'^inspector/'), ChromiumStylePerfTest), | 309 (re.compile(r'^inspector/'), ChromiumStylePerfTest), |
| 305 ] | 310 ] |
| 306 | 311 |
| 307 @classmethod | 312 @classmethod |
| 308 def create_perf_test(cls, port, test_name, path, test_runner_count=DEFAULT_T
EST_RUNNER_COUNT): | 313 def create_perf_test(cls, port, test_name, path, test_runner_count=DEFAULT_T
EST_RUNNER_COUNT): |
| 309 for (pattern, test_class) in cls._pattern_map: | 314 for (pattern, test_class) in cls._pattern_map: |
| 310 if pattern.match(test_name): | 315 if pattern.match(test_name): |
| 311 return test_class(port, test_name, path, test_runner_count) | 316 return test_class(port, test_name, path, test_runner_count) |
| 312 return PerfTest(port, test_name, path, test_runner_count) | 317 return PerfTest(port, test_name, path, test_runner_count) |
| OLD | NEW |