OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2014 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 import time | |
6 | |
7 from metrics import power | |
8 from metrics import speedindex | |
9 from telemetry.core import util | |
10 from telemetry.page import page_measurement | |
11 | |
12 | |
13 class PowerManyTabs(page_measurement.PageMeasurement): | |
14 """Open several blank tabs, measure power after quiesencence.""" | |
tonyg
2014/02/27 06:42:17
This shouldn't talk about blank tabs. The page set
jeremy
2014/02/27 13:41:12
Makes sense, added a five_blank_tabs pageset.
| |
15 # Total number of tabs to open. | |
16 NUM_TABS = 5 | |
tonyg
2014/02/27 06:42:17
Should this be equal to the number of pages in the
jeremy
2014/02/27 13:41:12
Done.
| |
17 | |
18 # Amount of time to measure power usage for, in seconds. | |
19 POWER_MEAUSUREMENT_TIME_S = 5 | |
20 | |
21 def __init__(self, action_name_to_run=''): | |
22 super(PowerManyTabs, self).__init__( | |
23 needs_browser_restart_after_each_run=True, | |
24 action_name_to_run=action_name_to_run) | |
25 self._power_metric = power.PowerMetric() | |
26 | |
27 # This metric is not measured, we just use it's functionality to ascertain | |
28 # load completion. | |
tonyg
2014/02/27 06:42:17
Like we talked about offline, I recommend factorin
| |
29 self._speedindex_metric = speedindex.SpeedIndexMetric() | |
30 | |
31 def CustomizeBrowserOptions(self, options): | |
32 power.PowerMetric.CustomizeBrowserOptions(options) | |
33 | |
34 def MeasurePage(self, page, tab, results): | |
35 for _ in xrange(PowerManyTabs.NUM_TABS - 1): | |
36 tab.browser.tabs.New() | |
37 | |
38 def SpeedIndexIsFinished(): | |
39 return self._speedindex_metric.IsFinished(tab) | |
jeremy
2014/02/25 15:05:00
I'm not comfortable using speedindex like this, do
qsr
2014/02/25 15:11:15
Any reason to use speed index instead of usual pag
| |
40 util.WaitFor(SpeedIndexIsFinished, 60) | |
41 | |
42 # Measure power after quiescence. | |
43 self._power_metric.Start(page, tab) | |
44 time.sleep(PowerManyTabs.POWER_MEAUSUREMENT_TIME_S) | |
45 self._power_metric.Stop(page, tab) | |
46 | |
47 self._power_metric.AddResults(tab, results) | |
OLD | NEW |