| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2016 Google Inc. | 3 # Copyright 2016 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 from __future__ import print_function | 8 from __future__ import print_function |
| 9 from _benchresult import BenchResult | 9 from _benchresult import BenchResult |
| 10 from argparse import ArgumentParser | 10 from argparse import ArgumentParser |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 FLAGS = __argparse.parse_args() | 50 FLAGS = __argparse.parse_args() |
| 51 | 51 |
| 52 | 52 |
| 53 class Parser: | 53 class Parser: |
| 54 def __init__(self): | 54 def __init__(self): |
| 55 self.configs = list() # use list to preserve the order configs appear in. | 55 self.configs = list() # use list to preserve the order configs appear in. |
| 56 self.rows = collections.defaultdict(dict) | 56 self.rows = collections.defaultdict(dict) |
| 57 self.cols = collections.defaultdict(dict) | 57 self.cols = collections.defaultdict(dict) |
| 58 self.metric = None | 58 self.metric = None |
| 59 self.samples = None | |
| 60 self.sample_ms = None | 59 self.sample_ms = None |
| 61 | 60 |
| 62 def parse_file(self, infile): | 61 def parse_file(self, infile): |
| 63 for line in infile: | 62 for line in infile: |
| 64 match = BenchResult.match(line) | 63 match = BenchResult.match(line) |
| 65 if not match: | 64 if not match: |
| 66 continue | 65 continue |
| 67 if self.metric is None: | 66 if self.metric is None: |
| 68 self.metric = match.metric | 67 self.metric = match.metric |
| 69 elif match.metric != self.metric: | 68 elif match.metric != self.metric: |
| 70 raise ValueError("results have mismatched metrics (%s and %s)" % | 69 raise ValueError("results have mismatched metrics (%s and %s)" % |
| 71 (self.metric, match.metric)) | 70 (self.metric, match.metric)) |
| 72 if self.samples is None: | |
| 73 self.samples = match.samples | |
| 74 elif not FLAGS.force and match.samples != self.samples: | |
| 75 raise ValueError("results have mismatched number of samples. " | |
| 76 "(use --force to ignore)") | |
| 77 if self.sample_ms is None: | 71 if self.sample_ms is None: |
| 78 self.sample_ms = match.sample_ms | 72 self.sample_ms = match.sample_ms |
| 79 elif not FLAGS.force and match.sample_ms != self.sample_ms: | 73 elif not FLAGS.force and match.sample_ms != self.sample_ms: |
| 80 raise ValueError("results have mismatched sampling times. " | 74 raise ValueError("results have mismatched sampling times. " |
| 81 "(use --force to ignore)") | 75 "(use --force to ignore)") |
| 82 if not match.config in self.configs: | 76 if not match.config in self.configs: |
| 83 self.configs.append(match.config) | 77 self.configs.append(match.config) |
| 84 self.rows[match.bench][match.config] = match.get_string(FLAGS.result) | 78 self.rows[match.bench][match.config] = match.get_string(FLAGS.result) |
| 85 self.cols[match.config][match.bench] = getattr(match, FLAGS.result) | 79 self.cols[match.config][match.bench] = getattr(match, FLAGS.result) |
| 86 | 80 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 pathname = os.path.join(dirname, basename) | 140 pathname = os.path.join(dirname, basename) |
| 147 with open(pathname, mode='w') as tmpfile: | 141 with open(pathname, mode='w') as tmpfile: |
| 148 parser.print_csv(outfile=tmpfile) | 142 parser.print_csv(outfile=tmpfile) |
| 149 fileuri = urlparse.urljoin('file:', urllib.pathname2url(pathname)) | 143 fileuri = urlparse.urljoin('file:', urllib.pathname2url(pathname)) |
| 150 print('opening %s' % fileuri) | 144 print('opening %s' % fileuri) |
| 151 webbrowser.open(fileuri) | 145 webbrowser.open(fileuri) |
| 152 | 146 |
| 153 | 147 |
| 154 if __name__ == '__main__': | 148 if __name__ == '__main__': |
| 155 main() | 149 main() |
| OLD | NEW |