Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: build/android/pylib/json_perf_parser.py

Issue 11090082: Move PerfTest TraceEvent to async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build break Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/common/android/trace_event_binding.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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
11 def GetAverageRunInfo(json_data, name): 11 def GetAverageRunInfo(json_data, name):
12 """Summarizes TraceEvent JSON data for performance metrics. 12 """Summarizes TraceEvent JSON data for performance metrics.
13 13
14 Example JSON Inputs (More tags can be added but these are required): 14 Example JSON Inputs (More tags can be added but these are required):
15 Measuring Duration: 15 Measuring Duration:
16 [ 16 [
17 { "cat": "Java", 17 { "cat": "Java",
18 "ts": 10000000000, 18 "ts": 10000000000,
19 "ph": "B", 19 "ph": "S",
20 "name": "TestTrace" 20 "name": "TestTrace"
21 }, 21 },
22 { "cat": "Java", 22 { "cat": "Java",
23 "ts": 10000004000, 23 "ts": 10000004000,
24 "ph": "E", 24 "ph": "F",
25 "name": "TestTrace" 25 "name": "TestTrace"
26 }, 26 },
27 ... 27 ...
28 ] 28 ]
29 29
30 Measuring Call Frequency (FPS): 30 Measuring Call Frequency (FPS):
31 [ 31 [
32 { "cat": "Java", 32 { "cat": "Java",
33 "ts": 10000000000, 33 "ts": 10000000000,
34 "ph": "I", 34 "ph": "I",
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return float(entry['ts']) / 1000.0 99 return float(entry['ts']) / 1000.0
100 100
101 result['units'] = 'ms' 101 result['units'] = 'ms'
102 else: 102 else:
103 raise Exception('Entry did not contain valid value info: %s' % entry) 103 raise Exception('Entry did not contain valid value info: %s' % entry)
104 104
105 if not val_type in entry: 105 if not val_type in entry:
106 raise Exception('Entry did not contain expected value type "%s" ' 106 raise Exception('Entry did not contain expected value type "%s" '
107 'information: %s' % (val_type, entry)) 107 'information: %s' % (val_type, entry))
108 val = GetVal(entry) 108 val = GetVal(entry)
109 if (entry['ph'] == 'B' and 109 if (entry['ph'] == 'S' and
110 (result['type'] == 'Unknown' or result['type'] == 'Span')): 110 (result['type'] == 'Unknown' or result['type'] == 'Span')):
111 result['type'] = 'Span' 111 result['type'] = 'Span'
112 last_val = val 112 last_val = val
113 elif ((entry['ph'] == 'E' and result['type'] == 'Span') or 113 elif ((entry['ph'] == 'F' and result['type'] == 'Span') or
114 (entry['ph'] == 'I' and (result['type'] == 'Unknown' or 114 (entry['ph'] == 'I' and (result['type'] == 'Unknown' or
115 result['type'] == 'Instant'))): 115 result['type'] == 'Instant'))):
116 if last_val > 0: 116 if last_val > 0:
117 delta = val - last_val 117 delta = val - last_val
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
(...skipping 27 matching lines...) Expand all
151 name: The 'name' tag to filter on in the JSON file. 151 name: The 'name' tag to filter on in the JSON file.
152 152
153 Returns: 153 Returns:
154 See GetAverageRunInfo Returns section. 154 See GetAverageRunInfo Returns section.
155 """ 155 """
156 with open(json_file, 'r') as f: 156 with open(json_file, 'r') as f:
157 data = f.read() 157 data = f.read()
158 perf = json.loads(data) 158 perf = json.loads(data)
159 159
160 return GetAverageRunInfo(perf, name) 160 return GetAverageRunInfo(perf, name)
OLDNEW
« no previous file with comments | « no previous file | content/common/android/trace_event_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698