OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 os | 5 import os |
6 | 6 |
| 7 from measurements import smoothness_controller |
| 8 from measurements import timeline_controller |
| 9 from telemetry import benchmark |
7 from telemetry.core.platform import tracing_category_filter | 10 from telemetry.core.platform import tracing_category_filter |
8 from telemetry.core.platform import tracing_options | 11 from telemetry.core.platform import tracing_options |
| 12 from telemetry.page import page_test |
9 from telemetry.page.actions import action_runner | 13 from telemetry.page.actions import action_runner |
10 from telemetry.page import page_test | 14 from telemetry.results import results_options |
11 from telemetry.timeline.model import TimelineModel | 15 from telemetry.timeline.model import TimelineModel |
12 from telemetry.util import statistics | 16 from telemetry.util import statistics |
13 from telemetry.value import list_of_scalar_values | 17 from telemetry.value import list_of_scalar_values |
14 from telemetry.value import scalar | 18 from telemetry.value import scalar |
15 from telemetry.value import trace | 19 from telemetry.value import trace |
16 | 20 |
17 from measurements import smoothness_controller | |
18 from measurements import timeline_controller | |
19 | |
20 | 21 |
21 _CR_RENDERER_MAIN = 'CrRendererMain' | 22 _CR_RENDERER_MAIN = 'CrRendererMain' |
22 _RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' | 23 _RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
23 _NAMES_TO_DUMP = ['oilpan_precise_mark', | 24 _GC_REASONS = ['precise', 'conservative', 'idle', 'forced'] |
24 'oilpan_precise_lazy_sweep', | 25 _GC_STAGES = ['mark', 'lazy_sweep', 'complete_sweep'] |
25 'oilpan_precise_complete_sweep', | |
26 'oilpan_conservative_mark', | |
27 'oilpan_conservative_lazy_sweep', | |
28 'oilpan_conservative_complete_sweep', | |
29 'oilpan_coalesce'] | |
30 | 26 |
31 def _GetGcType(args): | 27 |
| 28 def _GetGcReason(args): |
32 # Old style | 29 # Old style |
33 if 'precise' in args: | 30 if 'precise' in args: |
34 if args['forced']: | 31 if args['forced']: |
35 return None | 32 return 'forced' |
36 return 'precise' if args['precise'] else 'conservative' | 33 return 'precise' if args['precise'] else 'conservative' |
37 | 34 |
38 if args['gcReason'] == 'ForcedGCForTesting': | |
39 return None | |
40 if args['gcReason'] == 'ConservativeGC': | 35 if args['gcReason'] == 'ConservativeGC': |
41 return 'conservative' | 36 return 'conservative' |
42 if args['gcReason'] == 'PreciseGC': | 37 if args['gcReason'] == 'PreciseGC': |
43 return 'precise' | 38 return 'precise' |
| 39 if args['gcReason'] == 'ForcedGCForTesting': |
| 40 return 'forced' |
| 41 if args['gcReason'] == 'IdleGC': |
| 42 return 'idle' |
44 return None # Unknown | 43 return None # Unknown |
45 | 44 |
46 | 45 |
47 def _AddTracingResults(events, results): | 46 def _AddTracingResults(events, results): |
| 47 def DumpMetric(page, name, values, unit, results): |
| 48 if values[name]: |
| 49 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 50 page, name, unit, values[name])) |
| 51 results.AddValue(scalar.ScalarValue( |
| 52 page, name + '_max', unit, max(values[name]))) |
| 53 results.AddValue(scalar.ScalarValue( |
| 54 page, name + '_total', unit, sum(values[name]))) |
| 55 |
48 # Prepare | 56 # Prepare |
49 values = {} | 57 values = {'oilpan_coalesce': []} |
50 for name in _NAMES_TO_DUMP: | 58 for reason in _GC_REASONS: |
51 values[name] = [] | 59 for stage in _GC_STAGES: |
| 60 values['oilpan_%s_%s' % (reason, stage)] = [] |
52 | 61 |
53 # Parse in time line | 62 # Parse in time line |
54 gc_type = None | 63 reason = None |
55 mark_time = 0 | 64 mark_time = 0 |
56 lazy_sweep_time = 0 | 65 lazy_sweep_time = 0 |
57 complete_sweep_time = 0 | 66 complete_sweep_time = 0 |
58 for event in events: | 67 for event in events: |
59 duration = event.thread_duration or event.duration | 68 duration = event.thread_duration or event.duration |
60 if event.name == 'ThreadHeap::coalesce': | 69 if event.name == 'ThreadHeap::coalesce': |
61 values['oilpan_coalesce'].append(duration) | 70 values['oilpan_coalesce'].append(duration) |
62 continue | 71 continue |
63 if event.name == 'Heap::collectGarbage': | 72 if event.name == 'Heap::collectGarbage': |
64 if not gc_type is None: | 73 if reason is not None: |
65 values['oilpan_%s_mark' % gc_type].append(mark_time) | 74 values['oilpan_%s_mark' % reason].append(mark_time) |
66 values['oilpan_%s_lazy_sweep' % gc_type].append(lazy_sweep_time) | 75 values['oilpan_%s_lazy_sweep' % reason].append(lazy_sweep_time) |
67 values['oilpan_%s_complete_sweep' % gc_type].append(complete_sweep_time) | 76 values['oilpan_%s_complete_sweep' % reason].append(complete_sweep_time) |
68 | 77 |
69 gc_type = _GetGcType(event.args) | 78 reason = _GetGcReason(event.args) |
70 mark_time = duration | 79 mark_time = duration |
71 lazy_sweep_time = 0 | 80 lazy_sweep_time = 0 |
72 complete_sweep_time = 0 | 81 complete_sweep_time = 0 |
73 continue | 82 continue |
74 if event.name == 'ThreadHeap::lazySweepPages': | 83 if event.name == 'ThreadHeap::lazySweepPages': |
75 lazy_sweep_time += duration | 84 lazy_sweep_time += duration |
76 continue | 85 continue |
77 if event.name == 'ThreadState::completeSweep': | 86 if event.name == 'ThreadState::completeSweep': |
78 complete_sweep_time += duration | 87 complete_sweep_time += duration |
79 continue | 88 continue |
80 | 89 |
81 if not gc_type is None: | 90 if reason is not None: |
82 values['oilpan_%s_mark' % gc_type].append(mark_time) | 91 values['oilpan_%s_mark' % reason].append(mark_time) |
83 values['oilpan_%s_lazy_sweep' % gc_type].append(lazy_sweep_time) | 92 values['oilpan_%s_lazy_sweep' % reason].append(lazy_sweep_time) |
84 values['oilpan_%s_complete_sweep' % gc_type].append(complete_sweep_time) | 93 values['oilpan_%s_complete_sweep' % reason].append(complete_sweep_time) |
85 | 94 |
86 # Dump | |
87 page = results.current_page | 95 page = results.current_page |
88 unit = 'ms' | 96 unit = 'ms' |
89 for name in _NAMES_TO_DUMP: | |
90 if values[name]: | |
91 results.AddValue(list_of_scalar_values.ListOfScalarValues( | |
92 page, name, unit, values[name])) | |
93 results.AddValue(scalar.ScalarValue( | |
94 page, name + '_max', unit, max(values[name]))) | |
95 results.AddValue(scalar.ScalarValue( | |
96 page, name + '_total', unit, sum(values[name]))) | |
97 | 97 |
98 # Summarize marking time | 98 # Dump each metric |
99 total_mark_time = 0 | 99 DumpMetric(page, 'oilpan_coalesce', values, unit, results) |
100 for gc_type in ['precise', 'conservative']: | 100 for reason in _GC_REASONS: |
101 total_mark_time += sum(values['oilpan_%s_mark' % gc_type]) | 101 for stage in _GC_STAGES: |
102 results.AddValue( | 102 DumpMetric(page, 'oilpan_%s_%s' % (reason, stage), values, unit, results) |
103 scalar.ScalarValue(page, 'oilpan_mark', unit, total_mark_time)) | 103 |
| 104 # Summarize each stage |
| 105 for stage in _GC_STAGES: |
| 106 total_time = 0 |
| 107 for reason in _GC_REASONS: |
| 108 total_time += sum(values['oilpan_%s_%s' % (reason, stage)]) |
| 109 results.AddValue( |
| 110 scalar.ScalarValue(page, 'oilpan_%s' % stage, unit, total_time)) |
104 | 111 |
105 # Summarize sweeping time | 112 # Summarize sweeping time |
106 total_sweep_time = 0 | 113 total_sweep_time = 0 |
107 for do_type in ['lazy_sweep', 'complete_sweep']: | 114 for stage in ['lazy_sweep', 'complete_sweep']: |
108 sweep_time = 0 | 115 sweep_time = 0 |
109 for gc_type in ['precise', 'conservative']: | 116 for reason in _GC_REASONS: |
110 sweep_time += sum(values['oilpan_%s_%s' % (gc_type, do_type)]) | 117 sweep_time += sum(values['oilpan_%s_%s' % (reason, stage)]) |
111 key = 'oilpan_%s' % do_type | 118 key = 'oilpan_%s' % stage |
112 results.AddValue(scalar.ScalarValue(page, key, unit, sweep_time)) | 119 results.AddValue(scalar.ScalarValue(page, key, unit, sweep_time)) |
113 total_sweep_time += sweep_time | 120 total_sweep_time += sweep_time |
114 results.AddValue( | 121 results.AddValue( |
115 scalar.ScalarValue(page, 'oilpan_sweep', unit, total_sweep_time)) | 122 scalar.ScalarValue(page, 'oilpan_sweep', unit, total_sweep_time)) |
116 | 123 |
117 gc_time = 0 | 124 gc_time = 0 |
118 for key in values: | 125 for key in values: |
119 gc_time += sum(values[key]) | 126 gc_time += sum(values[key]) |
120 results.AddValue(scalar.ScalarValue(page, 'oilpan_gc', unit, gc_time)) | 127 results.AddValue(scalar.ScalarValue(page, 'oilpan_gc', unit, gc_time)) |
121 | 128 |
122 | 129 |
123 class _OilpanGCTimesBase(page_test.PageTest): | 130 class _OilpanGCTimesBase(page_test.PageTest): |
124 def __init__(self): | 131 def __init__(self, action_name=''): |
125 super(_OilpanGCTimesBase, self).__init__() | 132 super(_OilpanGCTimesBase, self).__init__(action_name) |
126 self._timeline_model = None | 133 self._timeline_model = None |
127 | 134 |
128 def WillNavigateToPage(self, page, tab): | 135 def WillNavigateToPage(self, page, tab): |
129 # FIXME: Remove webkit.console when blink.console lands in chromium and | 136 # FIXME: Remove webkit.console when blink.console lands in chromium and |
130 # the ref builds are updated. crbug.com/386847 | 137 # the ref builds are updated. crbug.com/386847 |
131 categories = ['webkit.console', 'blink.console', 'blink_gc'] | 138 categories = ['webkit.console', 'blink.console', 'blink_gc'] |
132 category_filter = tracing_category_filter.TracingCategoryFilter() | 139 category_filter = tracing_category_filter.TracingCategoryFilter() |
133 for c in categories: | 140 for c in categories: |
134 category_filter.AddIncludedCategory(c) | 141 category_filter.AddIncludedCategory(c) |
135 options = tracing_options.TracingOptions() | 142 options = tracing_options.TracingOptions() |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 class OilpanGCTimesForInternals(_OilpanGCTimesBase): | 192 class OilpanGCTimesForInternals(_OilpanGCTimesBase): |
186 def __init__(self): | 193 def __init__(self): |
187 super(OilpanGCTimesForInternals, self).__init__() | 194 super(OilpanGCTimesForInternals, self).__init__() |
188 | 195 |
189 @classmethod | 196 @classmethod |
190 def CustomizeBrowserOptions(cls, options): | 197 def CustomizeBrowserOptions(cls, options): |
191 # 'expose-internals-for-testing' can be enabled on content shell. | 198 # 'expose-internals-for-testing' can be enabled on content shell. |
192 assert 'content-shell' in options.browser_type | 199 assert 'content-shell' in options.browser_type |
193 options.AppendExtraBrowserArgs(['--expose-internals-for-testing', | 200 options.AppendExtraBrowserArgs(['--expose-internals-for-testing', |
194 '--js-flags=--expose-gc']) | 201 '--js-flags=--expose-gc']) |
OLD | NEW |