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.
5 from metrics
import cpu
6 from metrics
import memory
7 from metrics
import power
8 from telemetry
.page
import page_measurement
11 class WebRTC(page_measurement
.PageMeasurement
):
12 """Gathers WebRTC-related metrics on a page set."""
15 super(WebRTC
, self
).__init
__('RunWebrtc')
16 self
._cpu
_metric
= None
17 self
._memory
_metric
= None
18 self
._power
_metric
= None
20 def WillStartBrowser(self
, browser
):
21 self
._power
_metric
= power
.PowerMetric(browser
)
23 def DidStartBrowser(self
, browser
):
24 self
._cpu
_metric
= cpu
.CpuMetric(browser
)
25 self
._memory
_metric
= memory
.MemoryMetric(browser
)
27 def DidNavigateToPage(self
, page
, tab
):
28 self
._cpu
_metric
.Start(page
, tab
)
29 self
._memory
_metric
.Start(page
, tab
)
30 self
._power
_metric
.Start(page
, tab
)
32 def CustomizeBrowserOptions(self
, options
):
33 memory
.MemoryMetric
.CustomizeBrowserOptions(options
)
34 options
.AppendExtraBrowserArgs('--use-fake-device-for-media-stream')
35 options
.AppendExtraBrowserArgs('--use-fake-ui-for-media-stream')
36 power
.PowerMetric
.CustomizeBrowserOptions(options
)
38 def MeasurePage(self
, page
, tab
, results
):
39 """Measure the page's performance."""
40 self
._memory
_metric
.Stop(page
, tab
)
41 self
._memory
_metric
.AddResults(tab
, results
)
43 self
._cpu
_metric
.Stop(page
, tab
)
44 self
._cpu
_metric
.AddResults(tab
, results
)
46 self
._power
_metric
.Stop(page
, tab
)
47 self
._power
_metric
.AddResults(tab
, results
)