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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « benchmarks/startup/noop.cc ('k') | benchmarks/startup/startup.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import os
6 import subprocess
7 import timeit
8
9
10 def run(args, paths):
11 rounds = 1000
12
13 # Because mojo_benchmark_startup terminates the process immediately when its
14 # MojoMain() is called. The overall execution time reflects the startup
15 # performance of the mojo shell.
16 startup_time = timeit.timeit(
17 ("subprocess.call(['%s', 'mojo:mojo_benchmark_startup'])" %
18 paths.mojo_shell_path),
19 "import subprocess", number=rounds)
20
21 # The execution time of a noop executable is also measured, in order to offset
22 # the cost of timeit()/subprocess.call()/etc.
23 noop_time = timeit.timeit(
24 ("subprocess.call(['%s'])" %
25 os.path.join(paths.build_dir, 'mojo_benchmark_startup_noop')),
26 "import subprocess", number=rounds)
27
28 # TODO(yzshen): Consider also testing the startup time when
29 # mojo_benchmark_startup is served by an HTTP server.
30
31 # Convert the execution time to milliseconds and compute the average for
32 # a single run.
33 result = (startup_time - noop_time) * 1000 / rounds
34 return ("Result: rounds tested: %d; average startup time: %f ms" %
35 (rounds, result))
OLDNEW
« 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