| 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 re | 7 import re |
| 8 import math | 8 import math |
| 9 | 9 |
| 10 # bench representation algorithm constant names | 10 # bench representation algorithm constant names |
| 11 ALGORITHM_AVERAGE = 'avg' | 11 ALGORITHM_AVERAGE = 'avg' |
| 12 ALGORITHM_MEDIAN = 'med' | 12 ALGORITHM_MEDIAN = 'med' |
| 13 ALGORITHM_MINIMUM = 'min' | 13 ALGORITHM_MINIMUM = 'min' |
| 14 ALGORITHM_25TH_PERCENTILE = '25th' | 14 ALGORITHM_25TH_PERCENTILE = '25th' |
| 15 | 15 |
| 16 # Regular expressions used throughout | 16 # Regular expressions used throughout. |
| 17 PER_SETTING_RE = '([^\s=]+)(?:=(\S+))?' | 17 PER_SETTING_RE = '([^\s=]+)(?:=(\S+))?' |
| 18 SETTINGS_RE = 'skia bench:((?:\s+' + PER_SETTING_RE + ')*)' | 18 SETTINGS_RE = 'skia bench:((?:\s+' + PER_SETTING_RE + ')*)' |
| 19 BENCH_RE = 'running bench (?:\[\d+ \d+\] )?\s*(\S+)' | 19 BENCH_RE = 'running bench (?:\[\d+ \d+\] )?\s*(\S+)' |
| 20 TIME_RE = '(?:(\w*)msecs = )?\s*((?:\d+\.\d+)(?:,\s*\d+\.\d+)*)' | 20 TIME_RE = '(?:(\w*)msecs = )?\s*((?:\d+\.\d+)(?:,\s*\d+\.\d+)*)' |
| 21 # non-per-tile benches have configs that don't end with ']' or '>' | 21 # non-per-tile benches have configs that don't end with ']' or '>' |
| 22 CONFIG_RE = '(\S+[^\]>]): ((?:' + TIME_RE + '\s+)+)' | 22 CONFIG_RE = '(\S+[^\]>]):\s+((?:' + TIME_RE + '\s+)+)' |
| 23 # per-tile bench lines are in the following format. Note that there are | 23 # per-tile bench lines are in the following format. Note that there are |
| 24 # non-averaged bench numbers in separate lines, which we ignore now due to | 24 # non-averaged bench numbers in separate lines, which we ignore now due to |
| 25 # their inaccuracy. | 25 # their inaccuracy. |
| 26 TILE_RE = (' tile_(\S+): tile \[\d+,\d+\] out of \[\d+,\d+\] <averaged>:' | 26 TILE_RE = (' tile_(\S+): tile \[\d+,\d+\] out of \[\d+,\d+\] <averaged>:' |
| 27 ' ((?:' + TIME_RE + '\s+)+)') | 27 ' ((?:' + TIME_RE + '\s+)+)') |
| 28 # for extracting tile layout | 28 # for extracting tile layout |
| 29 TILE_LAYOUT_RE = ' out of \[(\d+),(\d+)\] <averaged>: ' | 29 TILE_LAYOUT_RE = ' out of \[(\d+),(\d+)\] <averaged>: ' |
| 30 | 30 |
| 31 PER_SETTING_RE_COMPILED = re.compile(PER_SETTING_RE) | 31 PER_SETTING_RE_COMPILED = re.compile(PER_SETTING_RE) |
| 32 SETTINGS_RE_COMPILED = re.compile(SETTINGS_RE) | 32 SETTINGS_RE_COMPILED = re.compile(SETTINGS_RE) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 for new_time in TIME_RE_COMPILED.finditer(times): | 134 for new_time in TIME_RE_COMPILED.finditer(times): |
| 135 current_time_type = new_time.group(1) | 135 current_time_type = new_time.group(1) |
| 136 iters = [float(i) for i in | 136 iters = [float(i) for i in |
| 137 new_time.group(2).strip().split(',')] | 137 new_time.group(2).strip().split(',')] |
| 138 value_dic.setdefault(bench, {}).setdefault( | 138 value_dic.setdefault(bench, {}).setdefault( |
| 139 current_config, {}).setdefault(current_time_type, []).append( | 139 current_config, {}).setdefault(current_time_type, []).append( |
| 140 _ListAlgorithm(iters, representation).compute()) | 140 _ListAlgorithm(iters, representation).compute()) |
| 141 layout_dic.setdefault(bench, {}).setdefault( | 141 layout_dic.setdefault(bench, {}).setdefault( |
| 142 current_config, {}).setdefault(current_time_type, tile_layout) | 142 current_config, {}).setdefault(current_time_type, tile_layout) |
| 143 | 143 |
| 144 # TODO(bensong): switch to reading JSON output when available. This way we don't |
| 145 # need the RE complexities. |
| 144 def parse(settings, lines, representation=None): | 146 def parse(settings, lines, representation=None): |
| 145 """Parses bench output into a useful data structure. | 147 """Parses bench output into a useful data structure. |
| 146 | 148 |
| 147 ({str:str}, __iter__ -> str) -> [BenchDataPoint] | 149 ({str:str}, __iter__ -> str) -> [BenchDataPoint] |
| 148 representation is one of the ALGORITHM_XXX types.""" | 150 representation is one of the ALGORITHM_XXX types.""" |
| 149 | 151 |
| 150 benches = [] | 152 benches = [] |
| 151 current_bench = None | 153 current_bench = None |
| 152 bench_dic = {} # [bench][config][time_type] -> [list of bench values] | 154 bench_dic = {} # [bench][config][time_type] -> [list of bench values] |
| 153 # [bench][config][time_type] -> tile_layout | 155 # [bench][config][time_type] -> tile_layout |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 """ | 291 """ |
| 290 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( | 292 return '<a href="http://code.google.com/p/skia/source/detail?r=%s">%s</a>'%( |
| 291 revision_number, revision_number) | 293 revision_number, revision_number) |
| 292 | 294 |
| 293 def main(): | 295 def main(): |
| 294 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] | 296 foo = [[0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0]] |
| 295 LinearRegression(foo) | 297 LinearRegression(foo) |
| 296 | 298 |
| 297 if __name__ == "__main__": | 299 if __name__ == "__main__": |
| 298 main() | 300 main() |
| OLD | NEW |