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=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. | |
borenet
2014/03/17 19:14:42
Can you give some examples of what these run setti
benchen
2014/03/17 19:37:54
Added some. Seems like this is currently only used
borenet
2014/03/17 20:07:26
hmm.. Are all of the acceptable settings documente
| |
159 | |
160 Returns: | |
161 A list of BenchDataPoint objects. | |
162 """ | |
163 if not default_settings: | |
164 default_settings = {} | |
165 | |
166 revision_data_points = [] | |
167 file_list = os.listdir(directory) | |
168 file_list.sort() | |
169 for bench_file in file_list: | |
170 scalar_type = None | |
171 # Scalar type, if any, is in the bench filename after 'scalar_'. | |
172 if (bench_file.startswith('bench_' + revision + '_data_')): | |
173 if bench_file.find('scalar_') > 0: | |
174 components = bench_file.split('_') | |
175 scalar_type = components[components.index('scalar') + 1] | |
176 else: # Skips non skp bench files. | |
177 continue | |
178 | |
179 with open('/'.join([directory, bench_file]), 'r') as file_handle: | |
180 settings = default_settings | |
borenet
2014/03/17 19:14:42
This will point to the same object and will theref
benchen
2014/03/17 19:37:54
ah right. fixed.
On 2014/03/17 19:14:42, borenet w
| |
181 settings['scalar'] = scalar_type | |
182 revision_data_points.extend(parse(settings, file_handle, rep)) | |
183 | |
184 return revision_data_points | |
185 | |
150 # TODO(bensong): switch to reading JSON output when available. This way we don't | 186 # TODO(bensong): switch to reading JSON output when available. This way we don't |
151 # need the RE complexities. | 187 # need the RE complexities. |
152 def parse(settings, lines, representation=None): | 188 def parse(settings, lines, representation=None): |
153 """Parses bench output into a useful data structure. | 189 """Parses bench output into a useful data structure. |
154 | 190 |
155 ({str:str}, __iter__ -> str) -> [BenchDataPoint] | 191 ({str:str}, __iter__ -> str) -> [BenchDataPoint] |
156 representation is one of the ALGORITHM_XXX types.""" | 192 representation is one of the ALGORITHM_XXX types.""" |
157 | 193 |
158 benches = [] | 194 benches = [] |
159 current_bench = None | 195 current_bench = None |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 """ | 349 """ |
314 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( | 350 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( |
315 revision_number, revision_number) | 351 revision_number, revision_number) |
316 | 352 |
317 def main(): | 353 def main(): |
318 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] | 354 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] |
319 LinearRegression(foo) | 355 LinearRegression(foo) |
320 | 356 |
321 if __name__ == "__main__": | 357 if __name__ == "__main__": |
322 main() | 358 main() |
OLD | NEW |