Chromium Code Reviews| Index: bench/bench_util.py |
| diff --git a/bench/bench_util.py b/bench/bench_util.py |
| index 29ef1c473b22a59735bd4e1587918ec59d59f280..1b99575eddee71eb5455dd94ce7d722772dbd473 100644 |
| --- a/bench/bench_util.py |
| +++ b/bench/bench_util.py |
| @@ -4,6 +4,7 @@ Created on May 19, 2011 |
| @author: bungeman |
| ''' |
| +import os |
| import re |
| import math |
| @@ -147,6 +148,40 @@ def _ParseAndStoreTimes(config_re_compiled, is_per_tile, line, bench, |
| layout_dic.setdefault(bench, {}).setdefault( |
| current_config, {}).setdefault(current_time_type, tile_layout) |
| +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.
|
| + """Parses all the skp bench data in the given directory. |
| + |
| + Args: |
| + directory: string of path to input data directory. |
| + revision: git hash revision that matches the data to process. |
| + rep: bench representation algorithm, see bench_util.py. |
| + default_settings: dictionary of other run settings. |
| + |
| + Returns: |
| + A list of BenchDataPoint objects. |
| + """ |
| + revision_data_points = [] |
| + file_list = os.listdir(directory) |
| + file_list.sort() |
| + for bench_file in file_list: |
| + scalar_type = None |
| + # Scalar type, if any, is in the bench filename after 'scalar_'. |
| + if (bench_file.startswith('bench_' + revision + '_data_')): |
| + if bench_file.find('scalar_') > 0: |
| + components = bench_file.split('_') |
| + scalar_type = components[components.index('scalar') + 1] |
| + else: # Skips non skp bench files. |
| + continue |
| + |
| + 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:
|
| + |
| + 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
|
| + revision_data_points.extend( |
| + parse(default_settings, file_handle, rep)) |
| + file_handle.close() |
| + |
| + return revision_data_points |
| + |
| # TODO(bensong): switch to reading JSON output when available. This way we don't |
| # need the RE complexities. |
| def parse(settings, lines, representation=None): |