OLD | NEW |
(Empty) | |
| 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 |
| 5 from chrome_remote_control import multi_page_benchmark |
| 6 from chrome_remote_control import util |
| 7 |
| 8 def _Mean(l): |
| 9 return float(sum(l)) / len(l) if len(l) > 0 else 0.0 |
| 10 |
| 11 class Kraken(multi_page_benchmark.MultiPageBenchmark): |
| 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.runtime.Evaluate(js_is_done)) |
| 18 util.WaitFor(_IsDone, 300) |
| 19 |
| 20 js_get_results = """ |
| 21 var formElement = document.getElementsByTagName("input")[0]; |
| 22 decodeURIComponent(formElement.value.split("?")[1]); |
| 23 """ |
| 24 result_dict = eval(tab.runtime.Evaluate(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]) |
| 30 total += _Mean(result_dict[key]) |
| 31 results.Add('Total', 'ms', total) |
OLD | NEW |