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

Side by Side Diff: bench/bench_util.py

Issue 201423002: gen_bench_expectations to generate bench expectations files. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: adds reference to settings Created 6 years, 9 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
« no previous file with comments | « no previous file | bench/check_bench_regressions.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 ''' 1 '''
2 Created on May 19, 2011 2 Created on May 19, 2011
3 3
4 @author: bungeman 4 @author: bungeman
5 ''' 5 '''
6 6
7 import os
7 import re 8 import re
8 import math 9 import math
9 10
10 # bench representation algorithm constant names 11 # bench representation algorithm constant names
11 ALGORITHM_AVERAGE = 'avg' 12 ALGORITHM_AVERAGE = 'avg'
12 ALGORITHM_MEDIAN = 'med' 13 ALGORITHM_MEDIAN = 'med'
13 ALGORITHM_MINIMUM = 'min' 14 ALGORITHM_MINIMUM = 'min'
14 ALGORITHM_25TH_PERCENTILE = '25th' 15 ALGORITHM_25TH_PERCENTILE = '25th'
15 16
16 # Regular expressions used throughout. 17 # Regular expressions used throughout.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 for new_time in TIME_RE_COMPILED.finditer(times): 141 for new_time in TIME_RE_COMPILED.finditer(times):
141 current_time_type = new_time.group(1) 142 current_time_type = new_time.group(1)
142 iters = [float(i) for i in 143 iters = [float(i) for i in
143 new_time.group(2).strip().split(',')] 144 new_time.group(2).strip().split(',')]
144 value_dic.setdefault(bench, {}).setdefault( 145 value_dic.setdefault(bench, {}).setdefault(
145 current_config, {}).setdefault(current_time_type, []).append( 146 current_config, {}).setdefault(current_time_type, []).append(
146 iters) 147 iters)
147 layout_dic.setdefault(bench, {}).setdefault( 148 layout_dic.setdefault(bench, {}).setdefault(
148 current_config, {}).setdefault(current_time_type, tile_layout) 149 current_config, {}).setdefault(current_time_type, tile_layout)
149 150
151 def parse_skp_bench_data(directory, revision, rep, default_settings=None):
152 """Parses all the skp bench data in the given directory.
153
154 Args:
155 directory: string of path to input data directory.
156 revision: git hash revision that matches the data to process.
157 rep: bench representation algorithm, see bench_util.py.
158 default_settings: dictionary of other run settings. See writer.option() in
159 bench/benchmain.cpp.
160
161 Returns:
162 A list of BenchDataPoint objects.
163 """
164 revision_data_points = []
165 file_list = os.listdir(directory)
166 file_list.sort()
167 for bench_file in file_list:
168 scalar_type = None
169 # Scalar type, if any, is in the bench filename after 'scalar_'.
170 if (bench_file.startswith('bench_' + revision + '_data_')):
171 if bench_file.find('scalar_') > 0:
172 components = bench_file.split('_')
173 scalar_type = components[components.index('scalar') + 1]
174 else: # Skips non skp bench files.
175 continue
176
177 with open('/'.join([directory, bench_file]), 'r') as file_handle:
178 settings = dict(default_settings or {})
179 settings['scalar'] = scalar_type
180 revision_data_points.extend(parse(settings, file_handle, rep))
181
182 return revision_data_points
183
150 # TODO(bensong): switch to reading JSON output when available. This way we don't 184 # TODO(bensong): switch to reading JSON output when available. This way we don't
151 # need the RE complexities. 185 # need the RE complexities.
152 def parse(settings, lines, representation=None): 186 def parse(settings, lines, representation=None):
153 """Parses bench output into a useful data structure. 187 """Parses bench output into a useful data structure.
154 188
155 ({str:str}, __iter__ -> str) -> [BenchDataPoint] 189 ({str:str}, __iter__ -> str) -> [BenchDataPoint]
156 representation is one of the ALGORITHM_XXX types.""" 190 representation is one of the ALGORITHM_XXX types."""
157 191
158 benches = [] 192 benches = []
159 current_bench = None 193 current_bench = None
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 """ 347 """
314 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( 348 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%(
315 revision_number, revision_number) 349 revision_number, revision_number)
316 350
317 def main(): 351 def main():
318 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] 352 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]]
319 LinearRegression(foo) 353 LinearRegression(foo)
320 354
321 if __name__ == "__main__": 355 if __name__ == "__main__":
322 main() 356 main()
OLDNEW
« no previous file with comments | « no previous file | bench/check_bench_regressions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698