Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / tools / perf / perf_tools / octane.py
blobd6f4f1a91ed64fee8ccb7af58422fbf1d11fb9b1
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.
4 from telemetry.core import util
5 from telemetry.page import page_benchmark
7 class Octane(page_benchmark.PageBenchmark):
8 def MeasurePage(self, _, tab, results):
9 js_is_done = """
10 completed && !document.getElementById("progress-bar-container")"""
11 def _IsDone():
12 return bool(tab.EvaluateJavaScript(js_is_done))
13 util.WaitFor(_IsDone, 300, poll_interval=5)
15 js_get_results = """
16 var results = {}
17 var result_divs = document.querySelectorAll('.p-result');
18 for (var r in result_divs) {
19 if (result_divs[r].id && result_divs[r].id.indexOf('Result-') == 0)
20 var key = result_divs[r].id.replace('Result-', '');
21 results[key] = result_divs[r].innerHTML;
23 var main_banner = document.getElementById("main-banner").innerHTML;
24 var octane_score = main_banner.substr(main_banner.lastIndexOf(':') + 2);
25 results['score'] = octane_score;
26 JSON.stringify(results);
27 """
28 result_dict = eval(tab.EvaluateJavaScript(js_get_results))
29 for key, value in result_dict.iteritems():
30 if value == '...':
31 continue
32 data_type = 'unimportant'
33 if key == 'score':
34 data_type = 'default'
35 results.Add(key, 'score (bigger is better)', value, data_type=data_type)