| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 # found in the LICENSE file. |  | 
| 4 |  | 
| 5 import telemetry.core.timeline.event as timeline_event |  | 
| 6 |  | 
| 7 class Slice(timeline_event.TimelineEvent): |  | 
| 8   ''' A Slice represents an interval of time plus parameters associated |  | 
| 9   with that interval. |  | 
| 10 |  | 
| 11   NOTE: The Sample class implements the same interface as |  | 
| 12   Slice. These must be kept in sync. |  | 
| 13 |  | 
| 14   All time units are stored in milliseconds. |  | 
| 15   ''' |  | 
| 16   def __init__(self, category, name, timestamp, args=None, parent=None): |  | 
| 17     super(Slice, self).__init__( |  | 
| 18         name, timestamp, 0, args=args, parent=parent) |  | 
| 19     self._sub_slices = [] |  | 
| 20     self.category = category |  | 
| 21     self.did_not_finish = False |  | 
| 22 |  | 
| 23   @property |  | 
| 24   def sub_slices(self): |  | 
| 25     return self._sub_slices |  | 
| 26 |  | 
| 27   def AddSubSlice(self, sub_slice): |  | 
| 28     self._sub_slices.append(sub_slice) |  | 
| 29 |  | 
| 30   def _GetSubSlicesRecursive(self): |  | 
| 31     for sub_slice in self._sub_slices: |  | 
| 32       for s in sub_slice.GetAllSubSlices(): |  | 
| 33         yield s |  | 
| 34       yield sub_slice |  | 
| 35 |  | 
| 36   def GetAllSubSlices(self): |  | 
| 37     return list(self._GetSubSlicesRecursive()) |  | 
| 38 |  | 
| 39   def GetAllSubSlicesOfName(self, name): |  | 
| 40     return [e for e in self.GetAllSubSlices() if e.name == name] |  | 
| OLD | NEW | 
|---|