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

Side by Side Diff: tools/run_perf.py

Issue 1128933007: [test] Make perf runner able to pass extra flags to d8. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 def ChangeCWD(self, suite_path): 304 def ChangeCWD(self, suite_path):
305 """Changes the cwd to to path defined in the current graph. 305 """Changes the cwd to to path defined in the current graph.
306 306
307 The tests are supposed to be relative to the suite configuration. 307 The tests are supposed to be relative to the suite configuration.
308 """ 308 """
309 suite_dir = os.path.abspath(os.path.dirname(suite_path)) 309 suite_dir = os.path.abspath(os.path.dirname(suite_path))
310 bench_dir = os.path.normpath(os.path.join(*self.path)) 310 bench_dir = os.path.normpath(os.path.join(*self.path))
311 os.chdir(os.path.join(suite_dir, bench_dir)) 311 os.chdir(os.path.join(suite_dir, bench_dir))
312 312
313 def GetCommandFlags(self): 313 def GetCommandFlags(self, extra_flags=None):
314 suffix = ["--"] + self.test_flags if self.test_flags else [] 314 suffix = ["--"] + self.test_flags if self.test_flags else []
315 return self.flags + [self.main] + suffix 315 return self.flags + (extra_flags or []) + [self.main] + suffix
316 316
317 def GetCommand(self, shell_dir): 317 def GetCommand(self, shell_dir, extra_flags=None):
318 # TODO(machenbach): This requires +.exe if run on windows. 318 # TODO(machenbach): This requires +.exe if run on windows.
319 return [os.path.join(shell_dir, self.binary)] + self.GetCommandFlags() 319 cmd = [os.path.join(shell_dir, self.binary)]
320 return cmd + self.GetCommandFlags(extra_flags=extra_flags)
kjellander_chromium 2015/05/13 13:23:55 Do you have to pass them into GetCommandFlags beca
Michael Achenbach 2015/05/13 13:49:43 Yes they have to come before suffix as it contains
320 321
321 def Run(self, runner): 322 def Run(self, runner):
322 """Iterates over several runs and handles the output for all traces.""" 323 """Iterates over several runs and handles the output for all traces."""
323 for stdout in runner(): 324 for stdout in runner():
324 for trace in self._children: 325 for trace in self._children:
325 trace.ConsumeOutput(stdout) 326 trace.ConsumeOutput(stdout)
326 res = reduce(lambda r, t: r + t.GetResults(), self._children, Results()) 327 res = reduce(lambda r, t: r + t.GetResults(), self._children, Results())
327 328
328 if not res.traces or not self.total: 329 if not res.traces or not self.total:
329 return res 330 return res
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 def GetPlatform(options): 468 def GetPlatform(options):
468 if options.arch.startswith("android"): 469 if options.arch.startswith("android"):
469 return AndroidPlatform(options) 470 return AndroidPlatform(options)
470 else: 471 else:
471 return DesktopPlatform(options) 472 return DesktopPlatform(options)
472 473
473 474
474 class DesktopPlatform(Platform): 475 class DesktopPlatform(Platform):
475 def __init__(self, options): 476 def __init__(self, options):
476 self.shell_dir = options.shell_dir 477 self.shell_dir = options.shell_dir
478 self.extra_flags = options.extra_flags.split()
kjellander_chromium 2015/05/13 13:23:55 Move this whole constructor to Platform class to r
Michael Achenbach 2015/05/13 13:49:43 Will do. Followup coming...
477 479
478 def PreExecution(self): 480 def PreExecution(self):
479 pass 481 pass
480 482
481 def PostExecution(self): 483 def PostExecution(self):
482 pass 484 pass
483 485
484 def PreTests(self, node, path): 486 def PreTests(self, node, path):
485 if isinstance(node, Runnable): 487 if isinstance(node, Runnable):
486 node.ChangeCWD(path) 488 node.ChangeCWD(path)
487 489
488 def Run(self, runnable, count): 490 def Run(self, runnable, count):
489 try: 491 try:
490 output = commands.Execute(runnable.GetCommand(self.shell_dir), 492 output = commands.Execute(
491 timeout=runnable.timeout) 493 runnable.GetCommand(self.shell_dir, self.extra_flags),
494 timeout=runnable.timeout,
495 )
492 except OSError as e: 496 except OSError as e:
493 print ">>> OSError (#%d):" % (count + 1) 497 print ">>> OSError (#%d):" % (count + 1)
494 print e 498 print e
495 return "" 499 return ""
496 print ">>> Stdout (#%d):" % (count + 1) 500 print ">>> Stdout (#%d):" % (count + 1)
497 print output.stdout 501 print output.stdout
498 if output.stderr: # pragma: no cover 502 if output.stderr: # pragma: no cover
499 # Print stderr for debugging. 503 # Print stderr for debugging.
500 print ">>> Stderr (#%d):" % (count + 1) 504 print ">>> Stderr (#%d):" % (count + 1)
501 print output.stderr 505 print output.stderr
502 if output.timed_out: 506 if output.timed_out:
503 print ">>> Test timed out after %ss." % runnable.timeout 507 print ">>> Test timed out after %ss." % runnable.timeout
504 return output.stdout 508 return output.stdout
505 509
506 510
507 class AndroidPlatform(Platform): # pragma: no cover 511 class AndroidPlatform(Platform): # pragma: no cover
508 DEVICE_DIR = "/data/local/tmp/v8/" 512 DEVICE_DIR = "/data/local/tmp/v8/"
509 513
510 def __init__(self, options): 514 def __init__(self, options):
511 self.shell_dir = options.shell_dir 515 self.shell_dir = options.shell_dir
516 self.extra_flags = options.extra_flags.split()
512 LoadAndroidBuildTools(options.android_build_tools) 517 LoadAndroidBuildTools(options.android_build_tools)
kjellander_chromium 2015/05/13 13:23:55 Then this would just invoke the superclass constru
513 518
514 if not options.device: 519 if not options.device:
515 # Detect attached device if not specified. 520 # Detect attached device if not specified.
516 devices = pylib.android_commands.GetAttachedDevices( 521 devices = pylib.android_commands.GetAttachedDevices(
517 hardware=True, emulator=False, offline=False) 522 hardware=True, emulator=False, offline=False)
518 assert devices and len(devices) == 1, ( 523 assert devices and len(devices) == 1, (
519 "None or multiple devices detected. Please specify the device on " 524 "None or multiple devices detected. Please specify the device on "
520 "the command-line with --device") 525 "the command-line with --device")
521 options.device = devices[0] 526 options.device = devices[0]
522 adb_wrapper = pylib.android_commands.AndroidCommands(options.device) 527 adb_wrapper = pylib.android_commands.AndroidCommands(options.device)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 594
590 if isinstance(node, Runnable): 595 if isinstance(node, Runnable):
591 self._PushFile(bench_abs, node.main, bench_rel) 596 self._PushFile(bench_abs, node.main, bench_rel)
592 for resource in node.resources: 597 for resource in node.resources:
593 self._PushFile(bench_abs, resource, bench_rel) 598 self._PushFile(bench_abs, resource, bench_rel)
594 599
595 def Run(self, runnable, count): 600 def Run(self, runnable, count):
596 cache = cache_control.CacheControl(self.device) 601 cache = cache_control.CacheControl(self.device)
597 cache.DropRamCaches() 602 cache.DropRamCaches()
598 binary_on_device = AndroidPlatform.DEVICE_DIR + runnable.binary 603 binary_on_device = AndroidPlatform.DEVICE_DIR + runnable.binary
599 cmd = [binary_on_device] + runnable.GetCommandFlags() 604 cmd = [binary_on_device] + runnable.GetCommandFlags(self.extra_flags)
600 605
601 # Relative path to benchmark directory. 606 # Relative path to benchmark directory.
602 if runnable.path: 607 if runnable.path:
603 bench_rel = os.path.normpath(os.path.join(*runnable.path)) 608 bench_rel = os.path.normpath(os.path.join(*runnable.path))
604 else: 609 else:
605 bench_rel = "." 610 bench_rel = "."
606 611
607 try: 612 try:
608 output = self.device.RunShellCommand( 613 output = self.device.RunShellCommand(
609 cmd, 614 cmd,
(...skipping 19 matching lines...) Expand all
629 parser.add_option("--arch", 634 parser.add_option("--arch",
630 help=("The architecture to run tests for, " 635 help=("The architecture to run tests for, "
631 "'auto' or 'native' for auto-detect"), 636 "'auto' or 'native' for auto-detect"),
632 default="x64") 637 default="x64")
633 parser.add_option("--buildbot", 638 parser.add_option("--buildbot",
634 help="Adapt to path structure used on buildbots", 639 help="Adapt to path structure used on buildbots",
635 default=False, action="store_true") 640 default=False, action="store_true")
636 parser.add_option("--device", 641 parser.add_option("--device",
637 help="The device ID to run Android tests on. If not given " 642 help="The device ID to run Android tests on. If not given "
638 "it will be autodetected.") 643 "it will be autodetected.")
644 parser.add_option("--extra-flags",
645 help="Additional flags to pass to the test executable",
646 default="")
639 parser.add_option("--json-test-results", 647 parser.add_option("--json-test-results",
640 help="Path to a file for storing json results.") 648 help="Path to a file for storing json results.")
641 parser.add_option("--outdir", help="Base directory with compile output", 649 parser.add_option("--outdir", help="Base directory with compile output",
642 default="out") 650 default="out")
643 (options, args) = parser.parse_args(args) 651 (options, args) = parser.parse_args(args)
644 652
645 if len(args) == 0: # pragma: no cover 653 if len(args) == 0: # pragma: no cover
646 parser.print_help() 654 parser.print_help()
647 return 1 655 return 1
648 656
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 724
717 if options.json_test_results: 725 if options.json_test_results:
718 results.WriteToFile(options.json_test_results) 726 results.WriteToFile(options.json_test_results)
719 else: # pragma: no cover 727 else: # pragma: no cover
720 print results 728 print results
721 729
722 return min(1, len(results.errors)) 730 return min(1, len(results.errors))
723 731
724 if __name__ == "__main__": # pragma: no cover 732 if __name__ == "__main__": # pragma: no cover
725 sys.exit(Main(sys.argv[1:])) 733 sys.exit(Main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698