• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5from metrics import cpu
6from metrics import memory
7from metrics import power
8from telemetry.page import page_test
9
10
11class WebRTC(page_test.PageTest):
12  """Gathers WebRTC-related metrics on a page set."""
13
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
19
20  def WillStartBrowser(self, platform):
21    self._power_metric = power.PowerMetric(platform)
22
23  def DidStartBrowser(self, browser):
24    self._cpu_metric = cpu.CpuMetric(browser)
25    self._memory_metric = memory.MemoryMetric(browser)
26
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)
31
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)
37
38  def ValidateAndMeasurePage(self, page, tab, results):
39    """Measure the page's performance."""
40    self._memory_metric.Stop(page, tab)
41    self._memory_metric.AddResults(tab, results)
42
43    self._cpu_metric.Stop(page, tab)
44    self._cpu_metric.AddResults(tab, results)
45
46    self._power_metric.Stop(page, tab)
47    self._power_metric.AddResults(tab, results)
48