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 import itertools | 4 import itertools |
5 | 5 |
6 import telemetry.core.timeline.event_container as event_container | 6 import telemetry.core.timeline.event_container as event_container |
7 import telemetry.core.timeline.sample as tracing_sample | 7 import telemetry.core.timeline.sample as tracing_sample |
8 import telemetry.core.timeline.slice as tracing_slice | 8 import telemetry.core.timeline.slice as tracing_slice |
9 | 9 |
10 class Thread(event_container.TimelineEventContainer): | 10 class Thread(event_container.TimelineEventContainer): |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 for s in self.IterAllSlices(): | 57 for s in self.IterAllSlices(): |
58 if s.name == name: | 58 if s.name == name: |
59 yield s | 59 yield s |
60 | 60 |
61 def IterAllAsyncSlices(self): | 61 def IterAllAsyncSlices(self): |
62 for async_slice in self._async_slices: | 62 for async_slice in self._async_slices: |
63 yield async_slice | 63 yield async_slice |
64 for sub_slice in async_slice.IterEventsInThisContainerRecrusively(): | 64 for sub_slice in async_slice.IterEventsInThisContainerRecrusively(): |
65 yield sub_slice | 65 yield sub_slice |
66 | 66 |
| 67 def IterAllAsyncSlicesOfName(self, name): |
| 68 for s in self.IterAllAsyncSlices(): |
| 69 if s.name == name: |
| 70 yield s |
| 71 |
67 def IterEventsInThisContainer(self): | 72 def IterEventsInThisContainer(self): |
68 return itertools.chain( | 73 return itertools.chain( |
69 iter(self._newly_added_slices), | 74 iter(self._newly_added_slices), |
70 self.IterAllAsyncSlices(), | 75 self.IterAllAsyncSlices(), |
71 self.IterAllSlices(), | 76 self.IterAllSlices(), |
72 iter(self._samples) | 77 iter(self._samples) |
73 ) | 78 ) |
74 | 79 |
75 def AddSample(self, category, name, timestamp, args=None): | 80 def AddSample(self, category, name, timestamp, args=None): |
76 if len(self._samples) and timestamp < self._samples[-1].start: | 81 if len(self._samples) and timestamp < self._samples[-1].start: |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 # (whose end = start + duration) at the same time may become not equal. | 242 # (whose end = start + duration) at the same time may become not equal. |
238 # Tolerate 1ps error for slice.end. | 243 # Tolerate 1ps error for slice.end. |
239 if child.start >= root.start and child.end - root.end < 1e-9: | 244 if child.start >= root.start and child.end - root.end < 1e-9: |
240 if len(root.sub_slices) > 0: | 245 if len(root.sub_slices) > 0: |
241 if self._AddSliceIfBounds(root.sub_slices[-1], child): | 246 if self._AddSliceIfBounds(root.sub_slices[-1], child): |
242 return True | 247 return True |
243 child.parent_slice = root | 248 child.parent_slice = root |
244 root.AddSubSlice(child) | 249 root.AddSubSlice(child) |
245 return True | 250 return True |
246 return False | 251 return False |
OLD | NEW |