OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
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 """ | 6 """ |
7 Performance runner for d8. | 7 Performance runner for d8. |
8 | 8 |
9 Call e.g. with tools/run-benchmarks.py --arch ia32 some_suite.json | 9 Call e.g. with tools/run-benchmarks.py --arch ia32 some_suite.json |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 """Fake parent node with all default values.""" | 149 """Fake parent node with all default values.""" |
150 def __init__(self): | 150 def __init__(self): |
151 super(DefaultSentinel, self).__init__() | 151 super(DefaultSentinel, self).__init__() |
152 self.binary = "d8" | 152 self.binary = "d8" |
153 self.run_count = 10 | 153 self.run_count = 10 |
154 self.path = [] | 154 self.path = [] |
155 self.graphs = [] | 155 self.graphs = [] |
156 self.flags = [] | 156 self.flags = [] |
157 self.resources = [] | 157 self.resources = [] |
158 self.results_regexp = None | 158 self.results_regexp = None |
| 159 self.stddev_regexp = None |
159 self.units = "score" | 160 self.units = "score" |
160 | 161 |
161 | 162 |
162 class Graph(Node): | 163 class Graph(Node): |
163 """Represents a benchmark suite definition. | 164 """Represents a benchmark suite definition. |
164 | 165 |
165 Can either be a leaf or an inner node that provides default values. | 166 Can either be a leaf or an inner node that provides default values. |
166 """ | 167 """ |
167 def __init__(self, suite, parent, arch): | 168 def __init__(self, suite, parent, arch): |
168 super(Graph, self).__init__() | 169 super(Graph, self).__init__() |
(...skipping 20 matching lines...) Expand all Loading... |
189 # regexp and the current suite has none, a string place holder for the | 190 # regexp and the current suite has none, a string place holder for the |
190 # suite name is expected. | 191 # suite name is expected. |
191 # TODO(machenbach): Currently that makes only sense for the leaf level. | 192 # TODO(machenbach): Currently that makes only sense for the leaf level. |
192 # Multiple place holders for multiple levels are not supported. | 193 # Multiple place holders for multiple levels are not supported. |
193 if parent.results_regexp: | 194 if parent.results_regexp: |
194 regexp_default = parent.results_regexp % suite["name"] | 195 regexp_default = parent.results_regexp % suite["name"] |
195 else: | 196 else: |
196 regexp_default = None | 197 regexp_default = None |
197 self.results_regexp = suite.get("results_regexp", regexp_default) | 198 self.results_regexp = suite.get("results_regexp", regexp_default) |
198 | 199 |
| 200 # A similar regular expression for the standard deviation (optional). |
| 201 if parent.stddev_regexp: |
| 202 stddev_default = parent.stddev_regexp % suite["name"] |
| 203 else: |
| 204 stddev_default = None |
| 205 self.stddev_regexp = suite.get("stddev_regexp", stddev_default) |
| 206 |
199 | 207 |
200 class Trace(Graph): | 208 class Trace(Graph): |
201 """Represents a leaf in the benchmark suite tree structure. | 209 """Represents a leaf in the benchmark suite tree structure. |
202 | 210 |
203 Handles collection of measurements. | 211 Handles collection of measurements. |
204 """ | 212 """ |
205 def __init__(self, suite, parent, arch): | 213 def __init__(self, suite, parent, arch): |
206 super(Trace, self).__init__(suite, parent, arch) | 214 super(Trace, self).__init__(suite, parent, arch) |
207 assert self.results_regexp | 215 assert self.results_regexp |
208 self.results = [] | 216 self.results = [] |
209 self.errors = [] | 217 self.errors = [] |
| 218 self.stddev = "" |
210 | 219 |
211 def ConsumeOutput(self, stdout): | 220 def ConsumeOutput(self, stdout): |
212 try: | 221 try: |
213 self.results.append( | 222 self.results.append( |
214 re.search(self.results_regexp, stdout, re.M).group(1)) | 223 re.search(self.results_regexp, stdout, re.M).group(1)) |
215 except: | 224 except: |
216 self.errors.append("Regexp \"%s\" didn't match for benchmark %s." | 225 self.errors.append("Regexp \"%s\" didn't match for benchmark %s." |
217 % (self.results_regexp, self.graphs[-1])) | 226 % (self.results_regexp, self.graphs[-1])) |
218 | 227 |
| 228 try: |
| 229 if self.stddev_regexp and self.stddev: |
| 230 self.errors.append("Benchmark %s should only run once since a stddev " |
| 231 "is provided by the benchmark." % self.graphs[-1]) |
| 232 if self.stddev_regexp: |
| 233 self.stddev = re.search(self.stddev_regexp, stdout, re.M).group(1) |
| 234 except: |
| 235 self.errors.append("Regexp \"%s\" didn't match for benchmark %s." |
| 236 % (self.stddev_regexp, self.graphs[-1])) |
| 237 |
219 def GetResults(self): | 238 def GetResults(self): |
220 return Results([{ | 239 return Results([{ |
221 "graphs": self.graphs, | 240 "graphs": self.graphs, |
222 "units": self.units, | 241 "units": self.units, |
223 "results": self.results, | 242 "results": self.results, |
| 243 "stddev": self.stddev, |
224 }], self.errors) | 244 }], self.errors) |
225 | 245 |
226 | 246 |
227 class Runnable(Graph): | 247 class Runnable(Graph): |
228 """Represents a runnable benchmark suite definition (i.e. has a main file). | 248 """Represents a runnable benchmark suite definition (i.e. has a main file). |
229 """ | 249 """ |
230 @property | 250 @property |
231 def main(self): | 251 def main(self): |
232 return self._suite["main"] | 252 return self._suite["main"] |
233 | 253 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 412 |
393 if options.json_test_results: | 413 if options.json_test_results: |
394 results.WriteToFile(options.json_test_results) | 414 results.WriteToFile(options.json_test_results) |
395 else: # pragma: no cover | 415 else: # pragma: no cover |
396 print results | 416 print results |
397 | 417 |
398 return min(1, len(results.errors)) | 418 return min(1, len(results.errors)) |
399 | 419 |
400 if __name__ == "__main__": # pragma: no cover | 420 if __name__ == "__main__": # pragma: no cover |
401 sys.exit(Main(sys.argv[1:])) | 421 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |