Revert of Move NumberOfPlanesForGpuMemoryBufferFormat to gfx (patchset #4 id:120001...
[chromium-blink-merge.git] / tools / telemetry / experimental / telemetry_perf_test.py
blob81f6d24931e2af7e7f142ef67b416b2dd71c348a
1 #!/usr/bin/env python
2 # Copyright 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import os
7 import sys
8 import time
10 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
12 from telemetry.internal.browser import browser_finder
13 from telemetry.internal.browser import browser_options
16 def Main(args):
17 options = browser_options.BrowserFinderOptions()
18 parser = options.CreateParser('telemetry_perf_test.py')
19 options, args = parser.parse_args(args)
21 browser_to_create = browser_finder.FindBrowser(options)
22 assert browser_to_create
23 with browser_to_create.Create(options) as b:
24 tab = b.tabs[0]
26 # Measure round-trip-time for evaluate
27 times = []
28 for i in range(1000):
29 start = time.time()
30 tab.EvaluateJavaScript('%i * 2' % i)
31 times.append(time.time() - start)
32 N = float(len(times))
33 avg = sum(times, 0.0) / N
34 squared_diffs = [(t - avg) * (t - avg) for t in times]
35 stdev = sum(squared_diffs, 0.0) / (N - 1)
36 times.sort()
37 percentile_75 = times[int(0.75 * N)]
39 print "%s: avg=%f; stdev=%f; min=%f; 75th percentile = %f" % (
40 "Round trip time (seconds)",
41 avg, stdev, min(times), percentile_75)
43 return 0
46 if __name__ == '__main__':
47 sys.exit(Main(sys.argv[1:]))