| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 from core import perf_benchmark | 7 from core import perf_benchmark |
| 8 | 8 |
| 9 from telemetry import benchmark | |
| 10 from telemetry.timeline import tracing_category_filter | 9 from telemetry.timeline import tracing_category_filter |
| 11 from telemetry.web_perf import timeline_based_measurement | 10 from telemetry.web_perf import timeline_based_measurement |
| 12 | 11 |
| 13 import page_sets | 12 import page_sets |
| 14 | 13 |
| 15 | 14 |
| 16 RE_BENCHMARK_VALUES = re.compile('(fore|back)ground-memory_') | 15 class _MemoryBenchmark(perf_benchmark.PerfBenchmark): |
| 17 | 16 """Base class for timeline based memory benchmarks.""" |
| 18 | |
| 19 @benchmark.Enabled('android') | |
| 20 class MemoryHealthPlan(perf_benchmark.PerfBenchmark): | |
| 21 """Timeline based benchmark for the Memory Health Plan.""" | |
| 22 | |
| 23 page_set = page_sets.MemoryHealthStory | |
| 24 | 17 |
| 25 def SetExtraBrowserOptions(self, options): | 18 def SetExtraBrowserOptions(self, options): |
| 26 # TODO(perezju): Temporary workaround to disable periodic memory dumps. | 19 # TODO(perezju): Temporary workaround to disable periodic memory dumps. |
| 27 # See: http://crbug.com/513692 | 20 # See: http://crbug.com/513692 |
| 28 options.AppendExtraBrowserArgs('--enable-memory-benchmarking') | 21 options.AppendExtraBrowserArgs('--enable-memory-benchmarking') |
| 29 | 22 |
| 30 def CreateTimelineBasedMeasurementOptions(self): | 23 def CreateTimelineBasedMeasurementOptions(self): |
| 31 # Enable only memory-infra, to get memory dumps, and blink.console, to get | 24 # Enable only memory-infra, to get memory dumps, and blink.console, to get |
| 32 # the timeline markers used for mapping threads to tabs. | 25 # the timeline markers used for mapping threads to tabs. |
| 33 trace_memory = tracing_category_filter.TracingCategoryFilter( | 26 trace_memory = tracing_category_filter.TracingCategoryFilter( |
| 34 filter_string='-*,blink.console,disabled-by-default-memory-infra') | 27 filter_string='-*,blink.console,disabled-by-default-memory-infra') |
| 35 return timeline_based_measurement.Options(overhead_level=trace_memory) | 28 return timeline_based_measurement.Options(overhead_level=trace_memory) |
| 36 | 29 |
| 30 |
| 31 class MemoryHealthPlan(_MemoryBenchmark): |
| 32 """Timeline based benchmark for the Memory Health Plan.""" |
| 33 |
| 34 _RE_BENCHMARK_VALUES = re.compile('(fore|back)ground-memory_') |
| 35 |
| 36 page_set = page_sets.MemoryHealthStory |
| 37 |
| 37 @classmethod | 38 @classmethod |
| 38 def Name(cls): | 39 def Name(cls): |
| 39 return 'memory.memory_health_plan' | 40 return 'memory.memory_health_plan' |
| 40 | 41 |
| 41 @classmethod | 42 @classmethod |
| 42 def ValueCanBeAddedPredicate(cls, value, is_first_result): | 43 def ValueCanBeAddedPredicate(cls, value, is_first_result): |
| 43 return bool(RE_BENCHMARK_VALUES.match(value.name)) | 44 return bool(cls._RE_BENCHMARK_VALUES.match(value.name)) |
| 45 |
| 46 |
| 47 class RendererMemoryBlinkMemoryMobile(_MemoryBenchmark): |
| 48 """Timeline based benchmark for measuring memory consumption on mobile |
| 49 sites on which blink's memory consumption is relatively high.""" |
| 50 |
| 51 _RE_RENDERER_VALUES = re.compile('.+-memory_.+_renderer') |
| 52 |
| 53 page_set = page_sets.BlinkMemoryMobilePageSet |
| 54 |
| 55 @classmethod |
| 56 def Name(cls): |
| 57 return 'memory.blink_memory_mobile' |
| 58 |
| 59 @classmethod |
| 60 def ValueCanBeAddedPredicate(cls, value, is_first_result): |
| 61 return bool(cls._RE_RENDERER_VALUES.match(value.name)) |
| OLD | NEW |