Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / tools / perf / perf_tools / kraken.py
blobd09c01b673936b098f46a71cc9e1940dddb5509c
1 # Copyright (c) 2012 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.
5 from telemetry.core import util
6 from telemetry.page import page_benchmark
8 def _Mean(l):
9 return float(sum(l)) / len(l) if len(l) > 0 else 0.0
11 class Kraken(page_benchmark.PageBenchmark):
12 def MeasurePage(self, _, tab, results):
13 js_is_done = """
14 document.title.indexOf("Results") != -1 && document.readyState == "complete"
15 """
16 def _IsDone():
17 return bool(tab.EvaluateJavaScript(js_is_done))
18 util.WaitFor(_IsDone, 500, poll_interval=5)
20 js_get_results = """
21 var formElement = document.getElementsByTagName("input")[0];
22 decodeURIComponent(formElement.value.split("?")[1]);
23 """
24 result_dict = eval(tab.EvaluateJavaScript(js_get_results))
25 total = 0
26 for key in result_dict:
27 if key == 'v':
28 continue
29 results.Add(key, 'ms', result_dict[key], data_type='unimportant')
30 total += _Mean(result_dict[key])
31 results.Add('Total', 'ms', total)