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

Unified Diff: benchmarks/startup/run.py

Issue 724243002: Add a startup benchmark and rudimentary scripts for running benchmarks. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « benchmarks/startup/noop.cc ('k') | benchmarks/startup/startup.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: benchmarks/startup/run.py
diff --git a/benchmarks/startup/run.py b/benchmarks/startup/run.py
new file mode 100644
index 0000000000000000000000000000000000000000..c2479cb1b173266fd9f3742eba074bcf79977738
--- /dev/null
+++ b/benchmarks/startup/run.py
@@ -0,0 +1,35 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import timeit
+
+
+def run(args, paths):
+ rounds = 1000
+
+ # Because mojo_benchmark_startup terminates the process immediately when its
+ # MojoMain() is called. The overall execution time reflects the startup
+ # performance of the mojo shell.
+ startup_time = timeit.timeit(
+ ("subprocess.call(['%s', 'mojo:mojo_benchmark_startup'])" %
+ paths.mojo_shell_path),
+ "import subprocess", number=rounds)
+
+ # The execution time of a noop executable is also measured, in order to offset
+ # the cost of timeit()/subprocess.call()/etc.
+ noop_time = timeit.timeit(
+ ("subprocess.call(['%s'])" %
+ os.path.join(paths.build_dir, 'mojo_benchmark_startup_noop')),
+ "import subprocess", number=rounds)
+
+ # TODO(yzshen): Consider also testing the startup time when
+ # mojo_benchmark_startup is served by an HTTP server.
+
+ # Convert the execution time to milliseconds and compute the average for
+ # a single run.
+ result = (startup_time - noop_time) * 1000 / rounds
+ return ("Result: rounds tested: %d; average startup time: %f ms" %
+ (rounds, result))
« no previous file with comments | « benchmarks/startup/noop.cc ('k') | benchmarks/startup/startup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698