OLD | NEW |
---|---|
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 Loading... | |
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={}): | |
borenet
2014/03/17 17:43:05
Using an instance as a default is bad news. Inste
benchen
2014/03/17 19:02:40
Done.
| |
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. | |
159 | |
160 Returns: | |
161 A list of BenchDataPoint objects. | |
162 """ | |
163 revision_data_points = [] | |
164 file_list = os.listdir(directory) | |
165 file_list.sort() | |
166 for bench_file in file_list: | |
167 scalar_type = None | |
168 # Scalar type, if any, is in the bench filename after 'scalar_'. | |
169 if (bench_file.startswith('bench_' + revision + '_data_')): | |
170 if bench_file.find('scalar_') > 0: | |
171 components = bench_file.split('_') | |
172 scalar_type = components[components.index('scalar') + 1] | |
173 else: # Skips non skp bench files. | |
174 continue | |
175 | |
176 file_handle = open(directory + '/' + bench_file, 'r') | |
borenet
2014/03/17 17:43:05
Please use the "with" syntax:
with open('/'.join(
benchen
2014/03/17 19:02:40
ah just copied it over. Done.
On 2014/03/17 17:43:
| |
177 | |
178 default_settings['scalar'] = scalar_type | |
borenet
2014/03/17 17:43:05
Should we be modifying something that the caller h
benchen
2014/03/17 19:02:40
Good suggestion. Done.
On 2014/03/17 17:43:05, bor
| |
179 revision_data_points.extend( | |
180 parse(default_settings, file_handle, rep)) | |
181 file_handle.close() | |
182 | |
183 return revision_data_points | |
184 | |
150 # TODO(bensong): switch to reading JSON output when available. This way we don't | 185 # TODO(bensong): switch to reading JSON output when available. This way we don't |
151 # need the RE complexities. | 186 # need the RE complexities. |
152 def parse(settings, lines, representation=None): | 187 def parse(settings, lines, representation=None): |
153 """Parses bench output into a useful data structure. | 188 """Parses bench output into a useful data structure. |
154 | 189 |
155 ({str:str}, __iter__ -> str) -> [BenchDataPoint] | 190 ({str:str}, __iter__ -> str) -> [BenchDataPoint] |
156 representation is one of the ALGORITHM_XXX types.""" | 191 representation is one of the ALGORITHM_XXX types.""" |
157 | 192 |
158 benches = [] | 193 benches = [] |
159 current_bench = None | 194 current_bench = None |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 """ | 348 """ |
314 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( | 349 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( |
315 revision_number, revision_number) | 350 revision_number, revision_number) |
316 | 351 |
317 def main(): | 352 def main(): |
318 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] | 353 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] |
319 LinearRegression(foo) | 354 LinearRegression(foo) |
320 | 355 |
321 if __name__ == "__main__": | 356 if __name__ == "__main__": |
322 main() | 357 main() |
OLD | NEW |