[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / measurements / memory.py
blob4b22f6a888690d5d53212412218a3b21225d4fa3
1 # Copyright 2012 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 memory
8 from metrics import power
11 class Memory(page_test.PageTest):
12 def __init__(self):
13 super(Memory, self).__init__()
14 self._memory_metric = None
15 self._power_metric = None
17 def WillStartBrowser(self, platform):
18 self._power_metric = power.PowerMetric(platform)
20 def DidStartBrowser(self, browser):
21 self._memory_metric = memory.MemoryMetric(browser)
23 def WillNavigateToPage(self, page, tab):
24 tab.CollectGarbage()
26 def DidNavigateToPage(self, page, tab):
27 self._memory_metric.Start(page, tab)
28 self._power_metric.Start(page, tab)
30 def CustomizeBrowserOptions(self, options):
31 memory.MemoryMetric.CustomizeBrowserOptions(options)
32 # Since this is a memory benchmark, we want to sample memory histograms at
33 # a high frequency.
34 options.AppendExtraBrowserArgs('--memory-metrics')
36 def ValidateAndMeasurePage(self, page, tab, results):
37 self._power_metric.Stop(page, tab)
38 self._memory_metric.Stop(page, tab)
39 self._memory_metric.AddResults(tab, results)
40 self._power_metric.AddResults(tab, results)