| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 name: The passed in name filter. | 58 name: The passed in name filter. |
| 59 data_points: A list of all of the times used to generate this data. | 59 data_points: A list of all of the times used to generate this data. |
| 60 units: The units for the values being reported. | 60 units: The units for the values being reported. |
| 61 | 61 |
| 62 Raises: | 62 Raises: |
| 63 Exception: if entry contains invalid data. | 63 Exception: if entry contains invalid data. |
| 64 """ | 64 """ |
| 65 | 65 |
| 66 def EntryFilter(entry): | 66 def EntryFilter(entry): |
| 67 return entry['cat'] == 'Java' and entry['name'] == name | 67 return entry['cat'] == 'Java' and entry['name'] == name |
| 68 filtered_entries = filter(EntryFilter, json_data) | 68 filtered_entries = [j for j in json_data if EntryFilter(j)] |
| 69 | 69 |
| 70 result = {} | 70 result = {} |
| 71 | 71 |
| 72 result['min'] = -1 | 72 result['min'] = -1 |
| 73 result['max'] = -1 | 73 result['max'] = -1 |
| 74 result['average'] = 0 | 74 result['average'] = 0 |
| 75 result['count'] = 0 | 75 result['count'] = 0 |
| 76 result['type'] = 'Unknown' | 76 result['type'] = 'Unknown' |
| 77 result['category'] = 'Java' | 77 result['category'] = 'Java' |
| 78 result['name'] = name | 78 result['name'] = name |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 name: The 'name' tag to filter on in the JSON file. | 152 name: The 'name' tag to filter on in the JSON file. |
| 153 | 153 |
| 154 Returns: | 154 Returns: |
| 155 See GetAverageRunInfo Returns section. | 155 See GetAverageRunInfo Returns section. |
| 156 """ | 156 """ |
| 157 with open(json_file, 'r') as f: | 157 with open(json_file, 'r') as f: |
| 158 data = f.read() | 158 data = f.read() |
| 159 perf = json.loads(data) | 159 perf = json.loads(data) |
| 160 | 160 |
| 161 return GetAverageRunInfo(perf, name) | 161 return GetAverageRunInfo(perf, name) |
| OLD | NEW |