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: result['average'] = total_sum / result['count'] | 128 if result['count'] > 0: |
| 129 result['average'] = total_sum / result['count'] |
129 | 130 |
130 return result | 131 return result |
131 | 132 |
132 | 133 |
133 def GetAverageRunInfoFromJSONString(json_string, name): | 134 def GetAverageRunInfoFromJSONString(json_string, name): |
134 """Returns the results from GetAverageRunInfo using a JSON string. | 135 """Returns the results from GetAverageRunInfo using a JSON string. |
135 | 136 |
136 Args: | 137 Args: |
137 json_string: The string containing JSON. | 138 json_string: The string containing JSON. |
138 name: The 'name' tag to filter on in the JSON file. | 139 name: The 'name' tag to filter on in the JSON file. |
(...skipping 12 matching lines...) Expand all Loading... |
151 name: The 'name' tag to filter on in the JSON file. | 152 name: The 'name' tag to filter on in the JSON file. |
152 | 153 |
153 Returns: | 154 Returns: |
154 See GetAverageRunInfo Returns section. | 155 See GetAverageRunInfo Returns section. |
155 """ | 156 """ |
156 with open(json_file, 'r') as f: | 157 with open(json_file, 'r') as f: |
157 data = f.read() | 158 data = f.read() |
158 perf = json.loads(data) | 159 perf = json.loads(data) |
159 | 160 |
160 return GetAverageRunInfo(perf, name) | 161 return GetAverageRunInfo(perf, name) |
OLD | NEW |