Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: tools/telemetry/telemetry/web_perf/timeline_based_measurement_unittest.py

Issue 477463002: All smoke test for timeline-based is_fast measurement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/telemetry/unittest_data/interaction_enabled_page.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import unittest 6 import unittest
7 7
8 from telemetry import benchmark 8 from telemetry import benchmark
9 from telemetry.core import wpr_modes 9 from telemetry.core import wpr_modes
10 from telemetry.page import page as page_module 10 from telemetry.page import page as page_module
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 d.AddInteraction(ts=10, duration=5, marker=responsive_marker) 171 d.AddInteraction(ts=10, duration=5, marker=responsive_marker)
172 smooth_marker = 'Interaction.LogicalName/is_smooth,repeatable' 172 smooth_marker = 'Interaction.LogicalName/is_smooth,repeatable'
173 d.AddInteraction(ts=20, duration=5, marker=smooth_marker) 173 d.AddInteraction(ts=20, duration=5, marker=smooth_marker)
174 d.FinalizeImport() 174 d.FinalizeImport()
175 self.assertRaises(tbm_module.InvalidInteractions, d.AddResults) 175 self.assertRaises(tbm_module.InvalidInteractions, d.AddResults)
176 176
177 177
178 class TestTimelinebasedMeasurementPage(page_module.Page): 178 class TestTimelinebasedMeasurementPage(page_module.Page):
179 179
180 def __init__(self, ps, base_dir, trigger_animation=False, 180 def __init__(self, ps, base_dir, trigger_animation=False,
181 trigger_jank=False): 181 trigger_jank=False, trigger_slow=False):
182 super(TestTimelinebasedMeasurementPage, self).__init__( 182 super(TestTimelinebasedMeasurementPage, self).__init__(
183 'file://interaction_enabled_page.html', ps, base_dir) 183 'file://interaction_enabled_page.html', ps, base_dir)
184 self._trigger_animation = trigger_animation 184 self._trigger_animation = trigger_animation
185 self._trigger_jank = trigger_jank 185 self._trigger_jank = trigger_jank
186 self._trigger_slow = trigger_slow
186 187
187 def RunSmoothness(self, action_runner): 188 def RunSmoothness(self, action_runner):
188 if self._trigger_animation: 189 if self._trigger_animation:
189 action_runner.TapElement('#animating-button') 190 action_runner.TapElement('#animating-button')
190 action_runner.WaitForJavaScriptCondition('window.animationDone') 191 action_runner.WaitForJavaScriptCondition('window.animationDone')
191 if self._trigger_jank: 192 if self._trigger_jank:
192 action_runner.TapElement('#jank-button') 193 action_runner.TapElement('#jank-button')
193 action_runner.WaitForJavaScriptCondition('window.jankScriptDone') 194 action_runner.WaitForJavaScriptCondition('window.jankScriptDone')
195 if self._trigger_slow:
196 action_runner.TapElement('#slow-button')
197 action_runner.WaitForJavaScriptCondition('window.slowScriptDone')
194 198
195 199
196 class TimelineBasedMeasurementTest(page_test_test_case.PageTestTestCase): 200 class TimelineBasedMeasurementTest(page_test_test_case.PageTestTestCase):
197 201
198 def setUp(self): 202 def setUp(self):
199 self._options = options_for_unittests.GetCopy() 203 self._options = options_for_unittests.GetCopy()
200 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF 204 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF
201 205
202 def testSmoothnessTimelineBasedMeasurementForSmoke(self): 206 def testSmoothnessTimelineBasedMeasurementForSmoke(self):
203 ps = self.CreateEmptyPageSet() 207 ps = self.CreateEmptyPageSet()
204 ps.AddPage(TestTimelinebasedMeasurementPage( 208 ps.AddPage(TestTimelinebasedMeasurementPage(
205 ps, ps.base_dir, trigger_animation=True)) 209 ps, ps.base_dir, trigger_animation=True))
206 210
207 measurement = tbm_module.TimelineBasedMeasurement() 211 measurement = tbm_module.TimelineBasedMeasurement()
208 results = self.RunMeasurement(measurement, ps, 212 results = self.RunMeasurement(measurement, ps,
209 options=self._options) 213 options=self._options)
210 214
211 self.assertEquals(0, len(results.failures)) 215 self.assertEquals(0, len(results.failures))
212 v = results.FindAllPageSpecificValuesNamed('CenterAnimation-jank') 216 v = results.FindAllPageSpecificValuesNamed('CenterAnimation-jank')
213 self.assertEquals(len(v), 1) 217 self.assertEquals(len(v), 1)
214 v = results.FindAllPageSpecificValuesNamed('DrawerAnimation-jank') 218 v = results.FindAllPageSpecificValuesNamed('DrawerAnimation-jank')
215 self.assertEquals(len(v), 1) 219 self.assertEquals(len(v), 1)
216 220
221 def testFastTimelineBasedMeasurementForSmoke(self):
222 ps = self.CreateEmptyPageSet()
223 ps.AddPage(TestTimelinebasedMeasurementPage(
224 ps, ps.base_dir, trigger_slow=True))
225
226 measurement = tbm_module.TimelineBasedMeasurement()
227 results = self.RunMeasurement(measurement, ps, options=self._options)
228
229 self.assertEquals([], results.failures)
230 expected_names = [
231 'SlowThreadJsRun-fast-cpu_time',
232 'SlowThreadJsRun-fast-duration',
233 'SlowThreadJsRun-fast-idle_time',
234 ]
235 names = sorted(v.name for v in results.all_page_specific_values)
236 self.assertEquals(expected_names, names)
nednguyen 2014/08/14 01:33:47 Can you compare the two sets instead?
slamm 2014/08/14 17:27:08 Done.
237
nednguyen 2014/08/14 01:33:47 We can also assert duration >= 200 ms.
slamm 2014/08/14 17:27:09 Done.
217 # Disabled since mainthread_jank metric is not supported on windows platform. 238 # Disabled since mainthread_jank metric is not supported on windows platform.
218 @benchmark.Disabled('win') 239 @benchmark.Disabled('win')
219 def testMainthreadJankTimelineBasedMeasurement(self): 240 def testMainthreadJankTimelineBasedMeasurement(self):
220 ps = self.CreateEmptyPageSet() 241 ps = self.CreateEmptyPageSet()
221 ps.AddPage(TestTimelinebasedMeasurementPage( 242 ps.AddPage(TestTimelinebasedMeasurementPage(
222 ps, ps.base_dir, trigger_jank=True)) 243 ps, ps.base_dir, trigger_jank=True))
223 244
224 measurement = tbm_module.TimelineBasedMeasurement() 245 measurement = tbm_module.TimelineBasedMeasurement()
225 results = self.RunMeasurement(measurement, ps, 246 results = self.RunMeasurement(measurement, ps,
226 options=self._options) 247 options=self._options)
227 self.assertEquals(0, len(results.failures)) 248 self.assertEquals(0, len(results.failures))
228 249
229 # In interaction_enabled_page.html, we create a jank loop based on 250 # In interaction_enabled_page.html, we create a jank loop based on
230 # window.performance.now() (basically loop for x milliseconds). 251 # window.performance.now() (basically loop for x milliseconds).
231 # Since window.performance.now() uses wall-time 252 # Since window.performance.now() uses wall-time
232 # instead of thread time, we set time to looping to 100ms in 253 # instead of thread time, we set time to looping to 100ms in
233 # interaction_enabled_page.html and only assert the biggest jank > 50ms here 254 # interaction_enabled_page.html and only assert the biggest jank > 50ms here
234 # to account for the fact that the browser may deschedule during the jank 255 # to account for the fact that the browser may deschedule during the jank
235 # loop. 256 # loop.
236 v = results.FindAllPageSpecificValuesNamed( 257 v = results.FindAllPageSpecificValuesNamed(
237 'JankThreadJSRun-responsive-biggest_jank_thread_time') 258 'JankThreadJSRun-responsive-biggest_jank_thread_time')
238 self.assertGreaterEqual(v[0].value, 50) 259 self.assertGreaterEqual(v[0].value, 50)
239 260
240 v = results.FindAllPageSpecificValuesNamed( 261 v = results.FindAllPageSpecificValuesNamed(
241 'JankThreadJSRun-responsive-total_big_jank_thread_time') 262 'JankThreadJSRun-responsive-total_big_jank_thread_time')
242 self.assertGreaterEqual(v[0].value, 50) 263 self.assertGreaterEqual(v[0].value, 50)
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/unittest_data/interaction_enabled_page.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698