| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 # pylint: disable=R0201 | 5 # pylint: disable=R0201 |
| 6 | 6 |
| 7 """Log parsing for telemetry tests. | 7 """Log parsing for telemetry tests. |
| 8 | 8 |
| 9 The TelemetryResultsProcessor loads and contains results that were output in | 9 The TelemetryResultsProcessor loads and contains results that were output in |
| 10 JSON format from Telemetry. It can be used as a replacement for the classes in | 10 JSON format from Telemetry. It can be used as a replacement for the classes in |
| 11 the performance_log_processor module. | 11 the performance_log_processor module. |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import json | 14 import json |
| 15 import logging | 15 import logging |
| 16 import os | 16 import os |
| 17 | 17 |
| 18 from slave.performance_log_processor import _FormatHumanReadable |
| 19 |
| 20 |
| 18 class TelemetryResultsProcessor(object): | 21 class TelemetryResultsProcessor(object): |
| 19 | 22 |
| 20 def __init__(self, filename, is_ref): | 23 def __init__(self, filename, is_ref): |
| 21 self._chart_filename = filename | 24 self._chart_filename = filename |
| 22 self._is_reference_build = is_ref | 25 self._is_reference_build = is_ref |
| 23 | 26 |
| 24 def ChartJson(self): | 27 def ChartJson(self): |
| 25 try: | 28 try: |
| 26 return json.load(open(self._chart_filename)) | 29 return json.load(open(self._chart_filename)) |
| 27 except (IOError, ValueError): | 30 except (IOError, ValueError): |
| (...skipping 26 matching lines...) Expand all Loading... |
| 54 def FailedTests(self): | 57 def FailedTests(self): |
| 55 return [] | 58 return [] |
| 56 | 59 |
| 57 def SuppressionHashes(self): # pylint: disable=R0201 | 60 def SuppressionHashes(self): # pylint: disable=R0201 |
| 58 return [] | 61 return [] |
| 59 | 62 |
| 60 def ParsingErrors(self): # pylint: disable=R0201 | 63 def ParsingErrors(self): # pylint: disable=R0201 |
| 61 return [] | 64 return [] |
| 62 | 65 |
| 63 def PerformanceSummary(self): | 66 def PerformanceSummary(self): |
| 64 return '' | 67 """Writes the waterfall display text. |
| 68 |
| 69 The waterfall contains lines for each important trace, in the form |
| 70 tracename: value< (refvalue)> |
| 71 """ |
| 72 if self._is_reference_build: |
| 73 return [] |
| 74 |
| 75 results = [] |
| 76 for chart_name, chart_values in self.ChartJson()['charts'].iteritems(): |
| 77 if 'summary' in chart_values: |
| 78 summary = chart_values['summary'] |
| 79 if summary['important']: |
| 80 mean = sum(summary['values']) / float(len(summary['values'])) |
| 81 display = '%s: %s' % (chart_name, _FormatHumanReadable(mean)) |
| 82 results.append(display) |
| 83 return results |
| OLD | NEW |