| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 """A helper module for parsing JSON objects from perf tests results.""" | 6 """A helper module for parsing JSON objects from perf tests results.""" |
| 7 | 7 |
| 8 import json | 8 import json |
| 9 | 9 |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if result['min'] == -1 or result['min'] > delta: | 118 if result['min'] == -1 or result['min'] > delta: |
| 119 result['min'] = delta | 119 result['min'] = delta |
| 120 if result['max'] == -1 or result['max'] < delta: | 120 if result['max'] == -1 or result['max'] < delta: |
| 121 result['max'] = delta | 121 result['max'] = delta |
| 122 total_sum += delta | 122 total_sum += delta |
| 123 result['count'] += 1 | 123 result['count'] += 1 |
| 124 result['data_points'].append(delta) | 124 result['data_points'].append(delta) |
| 125 if entry['ph'] == 'I': | 125 if entry['ph'] == 'I': |
| 126 result['type'] = 'Instant' | 126 result['type'] = 'Instant' |
| 127 last_val = val | 127 last_val = val |
| 128 if result['count'] > 0: | 128 if result['count'] > 0: result['average'] = total_sum / result['count'] |
| 129 result['average'] = total_sum / result['count'] | |
| 130 | 129 |
| 131 return result | 130 return result |
| 132 | 131 |
| 133 | 132 |
| 134 def GetAverageRunInfoFromJSONString(json_string, name): | 133 def GetAverageRunInfoFromJSONString(json_string, name): |
| 135 """Returns the results from GetAverageRunInfo using a JSON string. | 134 """Returns the results from GetAverageRunInfo using a JSON string. |
| 136 | 135 |
| 137 Args: | 136 Args: |
| 138 json_string: The string containing JSON. | 137 json_string: The string containing JSON. |
| 139 name: The 'name' tag to filter on in the JSON file. | 138 name: The 'name' tag to filter on in the JSON file. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 152 name: The 'name' tag to filter on in the JSON file. | 151 name: The 'name' tag to filter on in the JSON file. |
| 153 | 152 |
| 154 Returns: | 153 Returns: |
| 155 See GetAverageRunInfo Returns section. | 154 See GetAverageRunInfo Returns section. |
| 156 """ | 155 """ |
| 157 with open(json_file, 'r') as f: | 156 with open(json_file, 'r') as f: |
| 158 data = f.read() | 157 data = f.read() |
| 159 perf = json.loads(data) | 158 perf = json.loads(data) |
| 160 | 159 |
| 161 return GetAverageRunInfo(perf, name) | 160 return GetAverageRunInfo(perf, name) |
| OLD | NEW |