From 758bc7aa483da5bf0bdb5e3dbc208902a8506a93 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 12 Mar 2014 16:23:33 +0000 Subject: [PATCH] Stores per-iteration bench values in BenchDataPoint. BUG=skia:2225 NOTRY=true R=borenet@google.com Author: bensong@google.com Review URL: https://codereview.chromium.org/197573002 git-svn-id: http://skia.googlecode.com/svn/trunk@13767 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/bench_util.py | 58 +++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/bench/bench_util.py b/bench/bench_util.py index 9b7d296fa..29ef1c473 100644 --- a/bench/bench_util.py +++ b/bench/bench_util.py @@ -38,19 +38,25 @@ TILE_LAYOUT_RE_COMPILED = re.compile(TILE_LAYOUT_RE) class BenchDataPoint: """A single data point produced by bench. - - (str, str, str, float, {str:str}, str, [floats])""" + """ def __init__(self, bench, config, time_type, time, settings, - tile_layout='', per_tile_values=[]): + tile_layout='', per_tile_values=[], per_iter_time=[]): + # string name of the benchmark to measure self.bench = bench + # string name of the configurations to run self.config = config + # type of the timer in string: '' (walltime), 'c' (cpu) or 'g' (gpu) self.time_type = time_type + # float number of the bench time value self.time = time + # dictionary of the run settings self.settings = settings - # how tiles cover the whole picture. '5x3' means 5 columns and 3 rows. + # how tiles cover the whole picture: '5x3' means 5 columns and 3 rows self.tile_layout = tile_layout - # list of per_tile bench values, if applicable + # list of float for per_tile bench values, if applicable self.per_tile_values = per_tile_values + # list of float for per-iteration bench time, if applicable + self.per_iter_time = per_iter_time def __repr__(self): return "BenchDataPoint(%s, %s, %s, %s, %s)" % ( @@ -109,7 +115,7 @@ class _ListAlgorithm(object): return self._rep def _ParseAndStoreTimes(config_re_compiled, is_per_tile, line, bench, - value_dic, layout_dic, representation=None): + value_dic, layout_dic): """Parses given bench time line with regex and adds data to value_dic. config_re_compiled: precompiled regular expression for parsing the config @@ -120,7 +126,7 @@ def _ParseAndStoreTimes(config_re_compiled, is_per_tile, line, bench, bench: name of bench for the time values. value_dic: dictionary to store bench values. See bench_dic in parse() below. layout_dic: dictionary to store tile layouts. See parse() for descriptions. - representation: should match one of the ALGORITHM_XXX types.""" + """ for config in config_re_compiled.finditer(line): current_config = config.group(1) @@ -137,7 +143,7 @@ def _ParseAndStoreTimes(config_re_compiled, is_per_tile, line, bench, new_time.group(2).strip().split(',')] value_dic.setdefault(bench, {}).setdefault( current_config, {}).setdefault(current_time_type, []).append( - _ListAlgorithm(iters, representation).compute()) + iters) layout_dic.setdefault(bench, {}).setdefault( current_config, {}).setdefault(current_time_type, tile_layout) @@ -151,7 +157,11 @@ def parse(settings, lines, representation=None): benches = [] current_bench = None - bench_dic = {} # [bench][config][time_type] -> [list of bench values] + # [bench][config][time_type] -> [[per-iter values]] where per-tile config + # has per-iter value list for each tile [[,,...], + # [,,...],...], while non-per-tile config only + # contains one list of iterations [[iter1, iter2, ...]]. + bench_dic = {} # [bench][config][time_type] -> tile_layout layout_dic = {} @@ -176,30 +186,42 @@ def parse(settings, lines, representation=None): if current_bench: if line.startswith(' tile_') : _ParseAndStoreTimes(TILE_RE_COMPILED, True, line, current_bench, - bench_dic, layout_dic, representation) + bench_dic, layout_dic) else: _ParseAndStoreTimes(CONFIG_RE_COMPILED, False, line, - current_bench, - bench_dic, layout_dic, representation) + current_bench, bench_dic, layout_dic) - # append benches to list, use the total time as final bench value. + # append benches to list for bench in bench_dic: for config in bench_dic[bench]: for time_type in bench_dic[bench][config]: tile_layout = '' - per_tile_values = [] + per_tile_values = [] # empty for non-per-tile configs + per_iter_time = [] # empty for per-tile configs + bench_summary = None # a single final bench value if len(bench_dic[bench][config][time_type]) > 1: - # per-tile values, extract tile_layout - per_tile_values = bench_dic[bench][config][time_type] + # per-tile config; compute representation for each tile + per_tile_values = [ + _ListAlgorithm(iters, representation).compute() + for iters in bench_dic[bench][config][time_type]] + # use sum of each tile representation for total bench value + bench_summary = sum(per_tile_values) + # extract tile layout tile_layout = layout_dic[bench][config][time_type] + else: + # get the list of per-iteration values + per_iter_time = bench_dic[bench][config][time_type][0] + bench_summary = _ListAlgorithm( + per_iter_time, representation).compute() benches.append(BenchDataPoint( bench, config, time_type, - sum(bench_dic[bench][config][time_type]), + bench_summary, settings, tile_layout, - per_tile_values)) + per_tile_values, + per_iter_time)) return benches