[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / benchmarks / memory_benchmark.py
blob27416db45b74b52ec240697d8af9c19dd305c7b4
1 # Copyright 2015 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 import re
7 from core import perf_benchmark
9 from telemetry import benchmark
10 from telemetry.timeline import tracing_category_filter
11 from telemetry.web_perf import timeline_based_measurement
13 import page_sets
16 class _MemoryBenchmark(perf_benchmark.PerfBenchmark):
17 """Base class for timeline based memory benchmarks."""
19 def SetExtraBrowserOptions(self, options):
20 # TODO(perezju): Temporary workaround to disable periodic memory dumps.
21 # See: http://crbug.com/513692
22 options.AppendExtraBrowserArgs('--enable-memory-benchmarking')
24 def CreateTimelineBasedMeasurementOptions(self):
25 # Enable only memory-infra, to get memory dumps, and blink.console, to get
26 # the timeline markers used for mapping threads to tabs.
27 trace_memory = tracing_category_filter.TracingCategoryFilter(
28 filter_string='-*,blink.console,disabled-by-default-memory-infra')
29 return timeline_based_measurement.Options(overhead_level=trace_memory)
32 # TODO(bashi): Workaround for http://crbug.com/532075
33 # @benchmark.Enabled('android') shouldn't be needed.
34 @benchmark.Enabled('android')
35 class MemoryHealthPlan(_MemoryBenchmark):
36 """Timeline based benchmark for the Memory Health Plan."""
38 _RE_BENCHMARK_VALUES = re.compile('(fore|back)ground-memory_')
40 page_set = page_sets.MemoryHealthStory
42 @classmethod
43 def Name(cls):
44 return 'memory.memory_health_plan'
46 @classmethod
47 def ValueCanBeAddedPredicate(cls, value, is_first_result):
48 return bool(cls._RE_BENCHMARK_VALUES.match(value.name))
51 # TODO(bashi): Workaround for http://crbug.com/532075
52 # @benchmark.Enabled('android') shouldn't be needed.
53 @benchmark.Enabled('android')
54 class RendererMemoryBlinkMemoryMobile(_MemoryBenchmark):
55 """Timeline based benchmark for measuring memory consumption on mobile
56 sites on which blink's memory consumption is relatively high."""
58 _RE_RENDERER_VALUES = re.compile('.+-memory_.+_renderer')
60 page_set = page_sets.BlinkMemoryMobilePageSet
62 def SetExtraBrowserOptions(self, options):
63 super(RendererMemoryBlinkMemoryMobile, self).SetExtraBrowserOptions(
64 options)
65 options.AppendExtraBrowserArgs([
66 # TODO(bashi): Temporary workaround for http://crbug.com/461788
67 '--no-sandbox',
68 # Ignore certs errors because record_wpr cannot handle certs correctly
69 # in some cases (e.g. WordPress).
70 '--ignore-certificate-errors',
73 @classmethod
74 def Name(cls):
75 return 'memory.blink_memory_mobile'
77 @classmethod
78 def ValueCanBeAddedPredicate(cls, value, is_first_result):
79 return bool(cls._RE_RENDERER_VALUES.match(value.name))