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 random | 5 import random |
6 import unittest | 6 import unittest |
7 | 7 |
8 from metrics.rendering_stats import RenderingStats | 8 from metrics.rendering_stats import RenderingStats |
9 from telemetry.core.timeline import model | 9 from telemetry.core.timeline import model |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 data = { 'frame_count': 0, | 53 data = { 'frame_count': 0, |
54 'paint_time': 0.0, | 54 'paint_time': 0.0, |
55 'painted_pixel_count': 0, | 55 'painted_pixel_count': 0, |
56 'record_time': mock_timer.Advance(2, 4) / 1000.0, | 56 'record_time': mock_timer.Advance(2, 4) / 1000.0, |
57 'recorded_pixel_count': 3000*3000 } | 57 'recorded_pixel_count': 3000*3000 } |
58 timestamp = mock_timer.Get() | 58 timestamp = mock_timer.Get() |
59 | 59 |
60 # Add a slice with the event data to the given thread. | 60 # Add a slice with the event data to the given thread. |
61 thread.PushCompleteSlice( | 61 thread.PushCompleteSlice( |
62 'benchmark', 'BenchmarkInstrumentation::MainThreadRenderingStats', | 62 'benchmark', 'BenchmarkInstrumentation::MainThreadRenderingStats', |
63 timestamp, 0.0, {'data': data}) | 63 timestamp, duration=0.0, thread_timestamp=None, thread_duration=None, |
| 64 args={'data': data}) |
64 | 65 |
65 if not ref_stats: | 66 if not ref_stats: |
66 return | 67 return |
67 | 68 |
68 # Add timestamp only if a frame was output | 69 # Add timestamp only if a frame was output |
69 if data['frame_count'] == 1: | 70 if data['frame_count'] == 1: |
70 if not first_frame: | 71 if not first_frame: |
71 # Add frame_time if this is not the first frame in within the bounds of an | 72 # Add frame_time if this is not the first frame in within the bounds of an |
72 # action. | 73 # action. |
73 prev_timestamp = ref_stats.frame_timestamps[-1] | 74 prev_timestamp = ref_stats.frame_timestamps[-1] |
(...skipping 16 matching lines...) Expand all Loading... |
90 """ | 91 """ |
91 # Create randonm data and timestap for impl thread rendering stats. | 92 # Create randonm data and timestap for impl thread rendering stats. |
92 data = { 'frame_count': 1, | 93 data = { 'frame_count': 1, |
93 'rasterize_time': mock_timer.Advance(5, 10) / 1000.0, | 94 'rasterize_time': mock_timer.Advance(5, 10) / 1000.0, |
94 'rasterized_pixel_count': 1280*720 } | 95 'rasterized_pixel_count': 1280*720 } |
95 timestamp = mock_timer.Get() | 96 timestamp = mock_timer.Get() |
96 | 97 |
97 # Add a slice with the event data to the given thread. | 98 # Add a slice with the event data to the given thread. |
98 thread.PushCompleteSlice( | 99 thread.PushCompleteSlice( |
99 'benchmark', 'BenchmarkInstrumentation::ImplThreadRenderingStats', | 100 'benchmark', 'BenchmarkInstrumentation::ImplThreadRenderingStats', |
100 timestamp, 0.0, {'data': data}) | 101 timestamp, duration=0.0, thread_timestamp=None, thread_duration=None, |
| 102 args={'data': data}) |
101 | 103 |
102 if not ref_stats: | 104 if not ref_stats: |
103 return | 105 return |
104 | 106 |
105 # Add timestamp only if a frame was output | 107 # Add timestamp only if a frame was output |
106 if data['frame_count'] == 1: | 108 if data['frame_count'] == 1: |
107 if not first_frame: | 109 if not first_frame: |
108 # Add frame_time if this is not the first frame in within the bounds of an | 110 # Add frame_time if this is not the first frame in within the bounds of an |
109 # action. | 111 # action. |
110 prev_timestamp = ref_stats.frame_timestamps[-1] | 112 prev_timestamp = ref_stats.frame_timestamps[-1] |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 self.assertEquals(stats.frame_timestamps, ref_stats.frame_timestamps) | 185 self.assertEquals(stats.frame_timestamps, ref_stats.frame_timestamps) |
184 self.assertEquals(stats.frame_times, ref_stats.frame_times) | 186 self.assertEquals(stats.frame_times, ref_stats.frame_times) |
185 self.assertEquals(stats.rasterize_time, ref_stats.rasterize_time) | 187 self.assertEquals(stats.rasterize_time, ref_stats.rasterize_time) |
186 self.assertEquals(stats.rasterized_pixel_count, | 188 self.assertEquals(stats.rasterized_pixel_count, |
187 ref_stats.rasterized_pixel_count) | 189 ref_stats.rasterized_pixel_count) |
188 self.assertEquals(stats.paint_time, ref_stats.paint_time) | 190 self.assertEquals(stats.paint_time, ref_stats.paint_time) |
189 self.assertEquals(stats.painted_pixel_count, ref_stats.painted_pixel_count) | 191 self.assertEquals(stats.painted_pixel_count, ref_stats.painted_pixel_count) |
190 self.assertEquals(stats.record_time, ref_stats.record_time) | 192 self.assertEquals(stats.record_time, ref_stats.record_time) |
191 self.assertEquals(stats.recorded_pixel_count, | 193 self.assertEquals(stats.recorded_pixel_count, |
192 ref_stats.recorded_pixel_count) | 194 ref_stats.recorded_pixel_count) |
OLD | NEW |