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

Side by Side Diff: tools/telemetry/telemetry/multi_page_benchmark.py

Issue 11348284: [telemetry] Adding --output-format option to enable more user-friendly output. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | tools/telemetry/telemetry/multi_page_benchmark_runner.py » ('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 from collections import defaultdict 4 from collections import defaultdict
5 import os 5 import os
6 import sys 6 import sys
7 7
8 from telemetry import page_test 8 from telemetry import page_test
9 9
10 # Get build/android/pylib scripts into our path. 10 # Get build/android/pylib scripts into our path.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 self.results_summary.iteritems()): 79 self.results_summary.iteritems()):
80 measurement, units, data_type = measurement_units_type 80 measurement, units, data_type = measurement_units_type
81 if '.' in measurement: 81 if '.' in measurement:
82 measurement, trace = measurement.split('.', 1) 82 measurement, trace = measurement.split('.', 1)
83 trace += (trace_tag or '') 83 trace += (trace_tag or '')
84 else: 84 else:
85 trace = measurement + (trace_tag or '') 85 trace = measurement + (trace_tag or '')
86 PrintPerfResult(measurement, trace, values, units, data_type) 86 PrintPerfResult(measurement, trace, values, units, data_type)
87 87
88 88
89 class CsvBenchmarkResults(BenchmarkResults): 89 class IncrementalBenchmarkResults(BenchmarkResults):
90 def __init__(self, results_writer): 90 def __init__(self):
91 super(CsvBenchmarkResults, self).__init__() 91 super(IncrementalBenchmarkResults, self).__init__()
92 self._results_writer = results_writer 92 self._did_process_header = False
93 self._did_write_header = False
94 93
95 def DidMeasurePage(self): 94 def DidMeasurePage(self):
96 super(CsvBenchmarkResults, self).DidMeasurePage() 95 super(IncrementalBenchmarkResults, self).DidMeasurePage()
97 96
98 if not self._did_write_header: 97 if not self._did_process_header:
99 self._did_write_header = True 98 self.ProcessHeader()
100 row = ['url']
101 for name in self.field_names:
102 row.append('%s (%s)' % (name, self.field_units[name]))
103 self._results_writer.writerow(row)
104 99
105 row = [self._page.url] 100 row = [self._page.url]
106 for name in self.field_names: 101 for name in self.field_names:
107 value = self._page_values[name] 102 value = self._page_values[name]
108 if self.field_types[name] == 'histogram': 103 if self.field_types[name] == 'histogram':
109 avg, _ = GeomMeanAndStdDevFromHistogram(value) 104 avg, _ = GeomMeanAndStdDevFromHistogram(value)
110 row.append(avg) 105 row.append(avg)
111 elif isinstance(value, list): 106 elif isinstance(value, list):
112 row.append(_Mean(value)) 107 row.append(_Mean(value))
113 else: 108 else:
114 row.append(value) 109 row.append(value)
110 self.OutputRow(row)
111
112 def OutputRow(self, row):
113 raise NotImplementedError()
114
115 def ProcessHeader(self):
116 raise NotImplementedError()
117
118 class CsvBenchmarkResults(IncrementalBenchmarkResults):
119 def __init__(self, results_writer):
120 super(CsvBenchmarkResults, self).__init__()
121 self._results_writer = results_writer
122
123 def OutputRow(self, row):
115 self._results_writer.writerow(row) 124 self._results_writer.writerow(row)
116 125
126 def ProcessHeader(self):
127 self._did_process_header = True
128 row = ['url']
129 for name in self.field_names:
130 row.append('%s (%s)' % (name, self.field_units[name]))
131 self.OutputRow(row)
132
133 class TerminalBlockBenchmarkResults(IncrementalBenchmarkResults):
134 def __init__(self, output_location):
135 super(TerminalBlockBenchmarkResults, self).__init__()
136 self._output_location = output_location
137 self._header_row = None
138
139 def OutputRow(self, row):
140 for i in range(len(row)):
141 print >> self._output_location, '%s:' % self._header_row[i], row[i]
142 print >> self._output_location
143
144 def ProcessHeader(self):
145 self._did_process_header = True
146 self._header_row = ['url']
147 for name in self.field_names:
148 self._header_row.append('%s (%s)' % (name, self.field_units[name]))
149
117 150
118 # TODO(nduca): Rename to page_benchmark 151 # TODO(nduca): Rename to page_benchmark
119 class MultiPageBenchmark(page_test.PageTest): 152 class MultiPageBenchmark(page_test.PageTest):
120 """Glue code for running a benchmark across a set of pages. 153 """Glue code for running a benchmark across a set of pages.
121 154
122 To use this, subclass from the benchmark and override MeasurePage. For 155 To use this, subclass from the benchmark and override MeasurePage. For
123 example: 156 example:
124 157
125 class BodyChildElementBenchmark(MultiPageBenchmark): 158 class BodyChildElementBenchmark(MultiPageBenchmark):
126 def MeasurePage(self, page, tab, results): 159 def MeasurePage(self, page, tab, results):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 202
170 Put together: 203 Put together:
171 204
172 def MeasurePage(self, page, tab, results): 205 def MeasurePage(self, page, tab, results):
173 res = tab.runtime.Evaluate('2+2') 206 res = tab.runtime.Evaluate('2+2')
174 if res != 4: 207 if res != 4:
175 raise Exception('Oh, wow.') 208 raise Exception('Oh, wow.')
176 results.Add('two_plus_two', 'count', res) 209 results.Add('two_plus_two', 'count', res)
177 """ 210 """
178 raise NotImplementedError() 211 raise NotImplementedError()
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/multi_page_benchmark_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698