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

Side by Side Diff: tools/skpbench/_benchresult.py

Issue 2390383002: Revert of skpbench: add option for gpu timing (Closed)
Patch Set: Created 4 years, 2 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 | « tools/gpu/gl/GLTestContext.cpp ('k') | tools/skpbench/parseskpbench.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 # Copyright 2016 Google Inc. 1 # Copyright 2016 Google Inc.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Parses an skpbench result from a line of output text.""" 6 """Parses an skpbench result from a line of output text."""
7 7
8 from __future__ import print_function 8 from __future__ import print_function
9 import re 9 import re
10 import sys 10 import sys
11 11
12 class BenchResult: 12 class BenchResult:
13 FLOAT_REGEX = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' 13 FLOAT_REGEX = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?'
14 PATTERN = re.compile('^(?P<accum_pad> *)' 14 PATTERN = re.compile('^(?P<accum_pad> *)'
15 '(?P<accum>' + FLOAT_REGEX + ')' 15 '(?P<accum>' + FLOAT_REGEX + ')'
16 '(?P<median_pad> +)' 16 '(?P<median_pad> +)'
17 '(?P<median>' + FLOAT_REGEX + ')' 17 '(?P<median>' + FLOAT_REGEX + ')'
18 '(?P<max_pad> +)' 18 '(?P<max_pad> +)'
19 '(?P<max>' + FLOAT_REGEX + ')' 19 '(?P<max>' + FLOAT_REGEX + ')'
20 '(?P<min_pad> +)' 20 '(?P<min_pad> +)'
21 '(?P<min>' + FLOAT_REGEX + ')' 21 '(?P<min>' + FLOAT_REGEX + ')'
22 '(?P<stddev_pad> +)' 22 '(?P<stddev_pad> +)'
23 '(?P<stddev>' + FLOAT_REGEX + '%)' 23 '(?P<stddev>' + FLOAT_REGEX + '%)'
24 '(?P<samples_pad> +)' 24 '(?P<samples_pad> +)'
25 '(?P<samples>\d+)' 25 '(?P<samples>\d+)'
26 '(?P<sample_ms_pad> +)' 26 '(?P<sample_ms_pad> +)'
27 '(?P<sample_ms>\d+)' 27 '(?P<sample_ms>\d+)'
28 '(?P<clock_pad> +)'
29 '(?P<clock>[cg]pu)'
30 '(?P<metric_pad> +)' 28 '(?P<metric_pad> +)'
31 '(?P<metric>ms|fps)' 29 '(?P<metric>ms|fps)'
32 '(?P<config_pad> +)' 30 '(?P<config_pad> +)'
33 '(?P<config>[^\s]+)' 31 '(?P<config>[^\s]+)'
34 '(?P<bench_pad> +)' 32 '(?P<bench_pad> +)'
35 '(?P<bench>[^\s]+)$') 33 '(?P<bench>[^\s]+)$')
36 34
37 @classmethod 35 @classmethod
38 def match(cls, text): 36 def match(cls, text):
39 match = cls.PATTERN.search(text) 37 match = cls.PATTERN.search(text)
40 return cls(match) if match else None 38 return cls(match) if match else None
41 39
42 def __init__(self, match): 40 def __init__(self, match):
43 self.accum = float(match.group('accum')) 41 self.accum = float(match.group('accum'))
44 self.median = float(match.group('median')) 42 self.median = float(match.group('median'))
45 self.max = float(match.group('max')) 43 self.max = float(match.group('max'))
46 self.min = float(match.group('min')) 44 self.min = float(match.group('min'))
47 self.stddev = float(match.group('stddev')[:-1]) # Drop '%' sign. 45 self.stddev = float(match.group('stddev')[:-1]) # Drop '%' sign.
48 self.samples = int(match.group('samples')) 46 self.samples = int(match.group('samples'))
49 self.sample_ms = int(match.group('sample_ms')) 47 self.sample_ms = int(match.group('sample_ms'))
50 self.clock = match.group('clock')
51 self.metric = match.group('metric') 48 self.metric = match.group('metric')
52 self.config = match.group('config') 49 self.config = match.group('config')
53 self.bench = match.group('bench') 50 self.bench = match.group('bench')
54 self._match = match 51 self._match = match
55 52
56 def get_string(self, name): 53 def get_string(self, name):
57 return self._match.group(name) 54 return self._match.group(name)
58 55
59 def print_values(self, config_suffix=None, outfile=sys.stdout): 56 def print_values(self, config_suffix=None, outfile=sys.stdout):
60 if not config_suffix or config_suffix == '': 57 if not config_suffix or config_suffix == '':
61 print(self._match.group(0), file=outfile) 58 print(self._match.group(0), file=outfile)
62 else: 59 else:
63 values = list() 60 values = list()
64 for name in ['accum', 'median', 'max', 'min', 'stddev', 61 for name in ['accum', 'median', 'max', 'min', 'stddev',
65 'samples', 'sample_ms', 'clock', 'metric', 'config']: 62 'samples', 'sample_ms', 'metric', 'config']:
66 values.append(self.get_string(name + '_pad')) 63 values.append(self.get_string(name + '_pad'))
67 values.append(self.get_string(name)) 64 values.append(self.get_string(name))
68 values.append(config_suffix) 65 values.append(config_suffix)
69 bench_pad = self.get_string('bench_pad') 66 bench_pad = self.get_string('bench_pad')
70 values.append(bench_pad[min(len(config_suffix), len(bench_pad) - 1):]) 67 values.append(bench_pad[min(len(config_suffix), len(bench_pad) - 1):])
71 values.append(self.get_string('bench')) 68 values.append(self.get_string('bench'))
72 print(''.join(values), file=outfile) 69 print(''.join(values), file=outfile)
OLDNEW
« no previous file with comments | « tools/gpu/gl/GLTestContext.cpp ('k') | tools/skpbench/parseskpbench.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698