| 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-perf.py --arch ia32 some_suite.json | 9 Call e.g. with tools/run-perf.py --arch ia32 some_suite.json |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 def AppendChild(self, child): | 157 def AppendChild(self, child): |
| 158 self._children.append(child) | 158 self._children.append(child) |
| 159 | 159 |
| 160 | 160 |
| 161 class DefaultSentinel(Node): | 161 class DefaultSentinel(Node): |
| 162 """Fake parent node with all default values.""" | 162 """Fake parent node with all default values.""" |
| 163 def __init__(self): | 163 def __init__(self): |
| 164 super(DefaultSentinel, self).__init__() | 164 super(DefaultSentinel, self).__init__() |
| 165 self.binary = "d8" | 165 self.binary = "d8" |
| 166 self.run_count = 10 | 166 self.run_count = 10 |
| 167 self.timeout = 60 |
| 167 self.path = [] | 168 self.path = [] |
| 168 self.graphs = [] | 169 self.graphs = [] |
| 169 self.flags = [] | 170 self.flags = [] |
| 170 self.resources = [] | 171 self.resources = [] |
| 171 self.results_regexp = None | 172 self.results_regexp = None |
| 172 self.stddev_regexp = None | 173 self.stddev_regexp = None |
| 173 self.units = "score" | 174 self.units = "score" |
| 174 self.total = False | 175 self.total = False |
| 175 | 176 |
| 176 | 177 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 191 # Accumulated values. | 192 # Accumulated values. |
| 192 self.path = parent.path[:] + suite.get("path", []) | 193 self.path = parent.path[:] + suite.get("path", []) |
| 193 self.graphs = parent.graphs[:] + [suite["name"]] | 194 self.graphs = parent.graphs[:] + [suite["name"]] |
| 194 self.flags = parent.flags[:] + suite.get("flags", []) | 195 self.flags = parent.flags[:] + suite.get("flags", []) |
| 195 self.resources = parent.resources[:] + suite.get("resources", []) | 196 self.resources = parent.resources[:] + suite.get("resources", []) |
| 196 | 197 |
| 197 # Descrete values (with parent defaults). | 198 # Descrete values (with parent defaults). |
| 198 self.binary = suite.get("binary", parent.binary) | 199 self.binary = suite.get("binary", parent.binary) |
| 199 self.run_count = suite.get("run_count", parent.run_count) | 200 self.run_count = suite.get("run_count", parent.run_count) |
| 200 self.run_count = suite.get("run_count_%s" % arch, self.run_count) | 201 self.run_count = suite.get("run_count_%s" % arch, self.run_count) |
| 202 self.timeout = suite.get("timeout", parent.timeout) |
| 201 self.units = suite.get("units", parent.units) | 203 self.units = suite.get("units", parent.units) |
| 202 self.total = suite.get("total", parent.total) | 204 self.total = suite.get("total", parent.total) |
| 203 | 205 |
| 204 # A regular expression for results. If the parent graph provides a | 206 # A regular expression for results. If the parent graph provides a |
| 205 # regexp and the current suite has none, a string place holder for the | 207 # regexp and the current suite has none, a string place holder for the |
| 206 # suite name is expected. | 208 # suite name is expected. |
| 207 # TODO(machenbach): Currently that makes only sense for the leaf level. | 209 # TODO(machenbach): Currently that makes only sense for the leaf level. |
| 208 # Multiple place holders for multiple levels are not supported. | 210 # Multiple place holders for multiple levels are not supported. |
| 209 if parent.results_regexp: | 211 if parent.results_regexp: |
| 210 regexp_default = parent.results_regexp % re.escape(suite["name"]) | 212 regexp_default = parent.results_regexp % re.escape(suite["name"]) |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 # If no name is given, default to the file name without .json. | 458 # If no name is given, default to the file name without .json. |
| 457 suite.setdefault("name", os.path.splitext(os.path.basename(path))[0]) | 459 suite.setdefault("name", os.path.splitext(os.path.basename(path))[0]) |
| 458 | 460 |
| 459 for runnable in FlattenRunnables(BuildGraphs(suite, options.arch)): | 461 for runnable in FlattenRunnables(BuildGraphs(suite, options.arch)): |
| 460 print ">>> Running suite: %s" % "/".join(runnable.graphs) | 462 print ">>> Running suite: %s" % "/".join(runnable.graphs) |
| 461 runnable.ChangeCWD(path) | 463 runnable.ChangeCWD(path) |
| 462 | 464 |
| 463 def Runner(): | 465 def Runner(): |
| 464 """Output generator that reruns several times.""" | 466 """Output generator that reruns several times.""" |
| 465 for i in xrange(0, max(1, runnable.run_count)): | 467 for i in xrange(0, max(1, runnable.run_count)): |
| 466 # TODO(machenbach): Make timeout configurable in the suite definition. | 468 # TODO(machenbach): Allow timeout per arch like with run_count per |
| 467 # Allow timeout per arch like with run_count per arch. | 469 # arch. |
| 468 output = commands.Execute(runnable.GetCommand(shell_dir), timeout=60) | 470 output = commands.Execute(runnable.GetCommand(shell_dir), |
| 471 timeout=runnable.timeout) |
| 469 print ">>> Stdout (#%d):" % (i + 1) | 472 print ">>> Stdout (#%d):" % (i + 1) |
| 470 print output.stdout | 473 print output.stdout |
| 471 if output.stderr: # pragma: no cover | 474 if output.stderr: # pragma: no cover |
| 472 # Print stderr for debugging. | 475 # Print stderr for debugging. |
| 473 print ">>> Stderr (#%d):" % (i + 1) | 476 print ">>> Stderr (#%d):" % (i + 1) |
| 474 print output.stderr | 477 print output.stderr |
| 478 if output.timed_out: |
| 479 print ">>> Test timed out after %ss." % runnable.timeout |
| 475 yield output.stdout | 480 yield output.stdout |
| 476 | 481 |
| 477 # Let runnable iterate over all runs and handle output. | 482 # Let runnable iterate over all runs and handle output. |
| 478 results += runnable.Run(Runner) | 483 results += runnable.Run(Runner) |
| 479 | 484 |
| 480 if options.json_test_results: | 485 if options.json_test_results: |
| 481 results.WriteToFile(options.json_test_results) | 486 results.WriteToFile(options.json_test_results) |
| 482 else: # pragma: no cover | 487 else: # pragma: no cover |
| 483 print results | 488 print results |
| 484 | 489 |
| 485 return min(1, len(results.errors)) | 490 return min(1, len(results.errors)) |
| 486 | 491 |
| 487 if __name__ == "__main__": # pragma: no cover | 492 if __name__ == "__main__": # pragma: no cover |
| 488 sys.exit(Main(sys.argv[1:])) | 493 sys.exit(Main(sys.argv[1:])) |
| OLD | NEW |