OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 unittest | 5 import unittest |
6 | 6 |
7 from telemetry.timeline import model as model_module | 7 from telemetry.timeline import model as model_module |
8 from telemetry.unittest_util import test_page_test_results | 8 from telemetry.unittest_util import test_page_test_results |
9 from telemetry.web_perf import timeline_interaction_record as tir_module | 9 from telemetry.web_perf import timeline_interaction_record as tir_module |
10 | 10 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) | 102 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) |
103 renderer_main.name = 'CrRendererMain' | 103 renderer_main.name = 'CrRendererMain' |
104 | 104 |
105 metric = timeline.ThreadTimesTimelineMetric() | 105 metric = timeline.ThreadTimesTimelineMetric() |
106 metric.details_to_report = timeline.ReportMainThreadOnly | 106 metric.details_to_report = timeline.ReportMainThreadOnly |
107 results = self.GetResults(metric, model, renderer_main.parent, | 107 results = self.GetResults(metric, model, renderer_main.parent, |
108 [_GetInteractionRecord(1,2)]) | 108 [_GetInteractionRecord(1,2)]) |
109 | 109 |
110 # Test that all result thread categories exist | 110 # Test that all result thread categories exist |
111 for name in timeline.TimelineThreadCategories.values(): | 111 for name in timeline.TimelineThreadCategories.values(): |
112 results.GetPageSpecificValueNamed(timeline.ThreadCpuTimeResultName(name)) | 112 results.GetPageSpecificValueNamed( |
113 timeline.ThreadCpuTimeResultName(name, 'frame')) | |
113 | 114 |
114 def testBasic(self): | 115 def testBasic(self): |
115 model = model_module.TimelineModel() | 116 model = model_module.TimelineModel() |
116 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) | 117 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) |
117 renderer_main.name = 'CrRendererMain' | 118 renderer_main.name = 'CrRendererMain' |
118 | 119 |
119 # Create two frame swaps (Results times should be divided by two) | 120 # Create two frame swaps (Results times should be divided by two) for |
121 # an interaction that lasts 20 milliseconds. | |
120 cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) | 122 cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) |
121 cc_main.name = 'Compositor' | 123 cc_main.name = 'Compositor' |
122 cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10) | 124 cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10) |
123 cc_main.EndSlice(11, 11) | 125 cc_main.EndSlice(11, 11) |
124 cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 12, 12) | 126 cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 12, 12) |
125 cc_main.EndSlice(13, 13) | 127 cc_main.EndSlice(13, 13) |
126 | 128 |
127 # [ X ] [ Z ] | 129 # [ X ] [ Z ] |
128 # [ Y ] | 130 # [ Y ] |
129 renderer_main.BeginSlice('cat1', 'X', 10, 0) | 131 renderer_main.BeginSlice('cat1', 'X', 10, 0) |
130 renderer_main.BeginSlice('cat2', 'Y', 15, 5) | 132 renderer_main.BeginSlice('cat2', 'Y', 15, 5) |
131 renderer_main.EndSlice(16, 5.5) | 133 renderer_main.EndSlice(16, 5.5) |
132 renderer_main.EndSlice(30, 19.5) | 134 renderer_main.EndSlice(30, 19.5) |
133 renderer_main.BeginSlice('cat1', 'Z', 31, 20) | 135 renderer_main.BeginSlice('cat1', 'Z', 31, 20) |
134 renderer_main.BeginSlice('cat1', 'Z', 33, 21) | 136 renderer_main.BeginSlice('cat1', 'Z', 33, 21) |
135 model.FinalizeImport() | 137 model.FinalizeImport() |
136 | 138 |
137 # Exclude 'Z' using an action-range. | 139 # Exclude 'Z' using an action-range. |
138 metric = timeline.ThreadTimesTimelineMetric() | 140 metric = timeline.ThreadTimesTimelineMetric() |
139 metric.details_to_report = timeline.ReportMainThreadOnly | 141 metric.details_to_report = timeline.ReportMainThreadOnly |
140 results = self.GetResults(metric, model, renderer_main.parent, | 142 results = self.GetResults(metric, model, renderer_main.parent, |
141 [_GetInteractionRecord(10, 30)]) | 143 [_GetInteractionRecord(10, 30)]) |
142 | 144 |
143 # Test for the results we expect. | 145 # Test for the results we expect. |
144 main_thread = "renderer_main" | 146 main_thread = "renderer_main" |
145 cc_thread = 'renderer_compositor' | 147 cc_thread = 'renderer_compositor' |
146 assert_results = [ | 148 assert_results = [ |
147 (timeline.ThreadCpuTimeResultName(main_thread), 'ms', 9.75), | 149 (timeline.ThreadCpuTimeResultName(main_thread, 'frame'), 'ms', 9.75), |
148 (timeline.ThreadTasksResultName(main_thread), 'tasks', 0.5), | 150 (timeline.ThreadTasksResultName(main_thread, 'frame'), 'tasks', 0.5), |
149 (timeline.ThreadMeanFrameTimeResultName(cc_thread), 'ms', 10.0), | 151 (timeline.ThreadMeanFrameTimeResultName(cc_thread), 'ms', 10.0), |
150 (timeline.ThreadDetailResultName(main_thread,'cat1'), 'ms', 9.5), | 152 (timeline.ThreadCpuTimeResultName(main_thread, 'ms'), 'ms', 0.975), |
151 (timeline.ThreadDetailResultName(main_thread,'cat2'), 'ms', 0.5), | 153 (timeline.ThreadTasksResultName(main_thread, 'ms'), 'tasks', 0.050), |
152 (timeline.ThreadDetailResultName(main_thread,'idle'), 'ms', 0) | 154 (timeline.ThreadCpuTimeResultName(cc_thread, 'ms'), 'ms', 0.1), |
155 (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat1'), | |
156 'ms', 9.5), | |
157 (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat2'), | |
158 'ms', 0.5), | |
159 (timeline.ThreadDetailResultName(main_thread, 'frame', 'idle'), 'ms', 0) | |
nednguyen
2015/05/04 00:39:46
What about the detail results for per ms cases?
jdduke (slow)
2015/05/04 17:46:20
Done.
| |
153 ] | 160 ] |
nednguyen
2015/05/04 00:39:46
Also can you add assertion for mean_frame_times to
jdduke (slow)
2015/05/04 17:46:20
Hmm, we already check timeline.ThreadMeanFrameTime
| |
154 for name, unit, value in assert_results: | 161 for name, unit, value in assert_results: |
155 results.AssertHasPageSpecificScalarValue(name, unit, value) | 162 results.AssertHasPageSpecificScalarValue(name, unit, value) |
156 | 163 |
157 def testOverheadIsRemoved(self): | 164 def testOverheadIsRemoved(self): |
158 model = model_module.TimelineModel() | 165 model = model_module.TimelineModel() |
159 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) | 166 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) |
160 renderer_main.name = 'CrRendererMain' | 167 renderer_main.name = 'CrRendererMain' |
161 | 168 |
162 # Create one frame swap. | 169 # Create one frame swap. |
163 cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) | 170 cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) |
(...skipping 12 matching lines...) Expand all Loading... | |
176 model.FinalizeImport() | 183 model.FinalizeImport() |
177 | 184 |
178 # Include everything in an action-range. | 185 # Include everything in an action-range. |
179 metric = timeline.ThreadTimesTimelineMetric() | 186 metric = timeline.ThreadTimesTimelineMetric() |
180 metric.details_to_report = timeline.ReportMainThreadOnly | 187 metric.details_to_report = timeline.ReportMainThreadOnly |
181 results = self.GetResults(metric, model, renderer_main.parent, | 188 results = self.GetResults(metric, model, renderer_main.parent, |
182 [_GetInteractionRecord(10, 30)]) | 189 [_GetInteractionRecord(10, 30)]) |
183 | 190 |
184 # Test a couple specific results. | 191 # Test a couple specific results. |
185 assert_results = { | 192 assert_results = { |
186 timeline.ThreadCpuTimeResultName('renderer_main') : 9.0, | 193 timeline.ThreadCpuTimeResultName('renderer_main', 'frame') : 9.0, |
187 } | 194 } |
188 for name, value in assert_results.iteritems(): | 195 for name, value in assert_results.iteritems(): |
189 results.AssertHasPageSpecificScalarValue(name, 'ms', value) | 196 results.AssertHasPageSpecificScalarValue(name, 'ms', value) |
OLD | NEW |