[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / measurements / webrtc.py
blobc8ac7d6f64847240371a592d1309a3f4ef556f55
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 telemetry.page import page_test
7 from metrics import cpu
8 from metrics import media
9 from metrics import memory
10 from metrics import power
11 from metrics import webrtc_stats
14 class WebRTC(page_test.PageTest):
15 """Gathers WebRTC-related metrics on a page set."""
17 def __init__(self):
18 super(WebRTC, self).__init__()
19 self._cpu_metric = None
20 self._media_metric = None
21 self._memory_metric = None
22 self._power_metric = None
23 self._webrtc_stats_metric = None
25 def WillStartBrowser(self, platform):
26 self._power_metric = power.PowerMetric(platform)
28 def DidStartBrowser(self, browser):
29 self._cpu_metric = cpu.CpuMetric(browser)
30 self._memory_metric = memory.MemoryMetric(browser)
31 self._webrtc_stats_metric = webrtc_stats.WebRtcStatisticsMetric()
33 def DidNavigateToPage(self, page, tab):
34 self._cpu_metric.Start(page, tab)
35 self._media_metric = media.MediaMetric(tab)
36 self._media_metric.Start(page, tab)
37 self._memory_metric.Start(page, tab)
38 self._power_metric.Start(page, tab)
39 self._webrtc_stats_metric.Start(page, tab)
41 def CustomizeBrowserOptions(self, options):
42 memory.MemoryMetric.CustomizeBrowserOptions(options)
43 options.AppendExtraBrowserArgs('--use-fake-device-for-media-stream')
44 options.AppendExtraBrowserArgs('--use-fake-ui-for-media-stream')
45 power.PowerMetric.CustomizeBrowserOptions(options)
47 def ValidateAndMeasurePage(self, page, tab, results):
48 """Measure the page's performance."""
49 self._cpu_metric.Stop(page, tab)
50 self._cpu_metric.AddResults(tab, results)
52 # Add all media metrics except bytes (those aren't hooked up for WebRTC
53 # video tags).
54 exclude_metrics = ['decoded_video_bytes', 'decoded_audio_bytes']
55 self._media_metric.Stop(page, tab)
56 self._media_metric.AddResults(tab, results, exclude_metrics=exclude_metrics)
58 self._memory_metric.Stop(page, tab)
59 self._memory_metric.AddResults(tab, results)
61 self._power_metric.Stop(page, tab)
62 self._power_metric.AddResults(tab, results)
64 self._webrtc_stats_metric.Stop(page, tab)
65 self._webrtc_stats_metric.AddResults(tab, results)