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

Side by Side Diff: tools/telemetry/examples/telemetry_perf_test.py

Issue 11361165: [chrome_remote_control] Rename chrome_remote_control to telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium 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 import os 5 import os
6 import sys 6 import sys
7 import time 7 import time
8 8
9 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 9 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
10 10
11 import chrome_remote_control 11 import telemetry
12 12
13 def Main(args): 13 def Main(args):
14 options = chrome_remote_control.BrowserOptions() 14 options = telemetry.BrowserOptions()
15 parser = options.CreateParser('crc_perf_test.py') 15 parser = options.CreateParser('telemetry_perf_test.py')
16 options, args = parser.parse_args(args) 16 options, args = parser.parse_args(args)
17 17
18 browser_to_create = chrome_remote_control.FindBrowser(options) 18 browser_to_create = telemetry.FindBrowser(options)
19 assert browser_to_create 19 assert browser_to_create
20 with browser_to_create.Create() as b: 20 with browser_to_create.Create() as b:
21 with b.ConnectToNthTab(0) as tab: 21 with b.ConnectToNthTab(0) as tab:
22 22
23 # Measure round-trip-time for evaluate 23 # Measure round-trip-time for evaluate
24 times = [] 24 times = []
25 for i in range(1000): 25 for i in range(1000):
26 start = time.time() 26 start = time.time()
27 tab.runtime.Evaluate('%i * 2' % i) 27 tab.runtime.Evaluate('%i * 2' % i)
28 times.append(time.time() - start) 28 times.append(time.time() - start)
29 N = float(len(times)) 29 N = float(len(times))
30 avg = sum(times, 0.0) / N 30 avg = sum(times, 0.0) / N
31 squared_diffs = [(t - avg) * (t - avg) for t in times] 31 squared_diffs = [(t - avg) * (t - avg) for t in times]
32 stdev = sum(squared_diffs, 0.0) / (N - 1) 32 stdev = sum(squared_diffs, 0.0) / (N - 1)
33 times.sort() 33 times.sort()
34 percentile_75 = times[int(0.75 * N)] 34 percentile_75 = times[int(0.75 * N)]
35 35
36 print "%s: avg=%f; stdev=%f; min=%f; 75th percentile = %f" % ( 36 print "%s: avg=%f; stdev=%f; min=%f; 75th percentile = %f" % (
37 "Round trip time (seconds)", 37 "Round trip time (seconds)",
38 avg, stdev, min(times), percentile_75) 38 avg, stdev, min(times), percentile_75)
39 39
40 return 0 40 return 0
41 41
42 if __name__ == '__main__': 42 if __name__ == '__main__':
43 sys.exit(Main(sys.argv[1:])) 43 sys.exit(Main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « tools/telemetry/examples/rendering_microbenchmark_test.py ('k') | tools/telemetry/examples/top1k » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698