blob: 81f6d24931e2af7e7f142ef67b416b2dd71c348a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/usr/bin/env python
# Copyright 2012 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 sys
import time
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
from telemetry.internal.browser import browser_finder
from telemetry.internal.browser import browser_options
def Main(args):
options = browser_options.BrowserFinderOptions()
parser = options.CreateParser('telemetry_perf_test.py')
options, args = parser.parse_args(args)
browser_to_create = browser_finder.FindBrowser(options)
assert browser_to_create
with browser_to_create.Create(options) as b:
tab = b.tabs[0]
# Measure round-trip-time for evaluate
times = []
for i in range(1000):
start = time.time()
tab.EvaluateJavaScript('%i * 2' % i)
times.append(time.time() - start)
N = float(len(times))
avg = sum(times, 0.0) / N
squared_diffs = [(t - avg) * (t - avg) for t in times]
stdev = sum(squared_diffs, 0.0) / (N - 1)
times.sort()
percentile_75 = times[int(0.75 * N)]
print "%s: avg=%f; stdev=%f; min=%f; 75th percentile = %f" % (
"Round trip time (seconds)",
avg, stdev, min(times), percentile_75)
return 0
if __name__ == '__main__':
sys.exit(Main(sys.argv[1:]))
|