[GCM] Persistence of account mappings.
[chromium-blink-merge.git] / tools / perf / measurements / webrtc.py
blob632f7bded9015b9c5129291e405ae3091ad4ca88
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."""
14 def __init__(self):
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)