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

Side by Side Diff: tools/android/loading/tracing.py

Issue 1813723002: clovis: Identify prefetchable resources from dependencies and tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 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 | « tools/android/loading/test_utils.py ('k') | tools/android/loading/tracing_unittest.py » ('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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 """Monitor tracing events on chrome via chrome remote debugging.""" 5 """Monitor tracing events on chrome via chrome remote debugging."""
6 6
7 import bisect 7 import bisect
8 import itertools 8 import itertools
9 import logging 9 import logging
10 import operator 10 import operator
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 sample and counter) events are never included. Event end times are 84 sample and counter) events are never included. Event end times are
85 exclusive, so that an event ending at the usec parameter will not be 85 exclusive, so that an event ending at the usec parameter will not be
86 returned. 86 returned.
87 """ 87 """
88 self._IndexEvents() 88 self._IndexEvents()
89 return self._interval_tree.EventsAt(msec) 89 return self._interval_tree.EventsAt(msec)
90 90
91 def ToJsonDict(self): 91 def ToJsonDict(self):
92 return {'events': [e.ToJsonDict() for e in self._events]} 92 return {'events': [e.ToJsonDict() for e in self._events]}
93 93
94 def TracingTrackForThread(self, pid_tid): 94 def Filter(self, pid=None, tid=None, categories=None):
95 """Returns a new TracingTrack with only the events from a given thread. 95 """Returns a new TracingTrack with a subset of the events.
96 96
97 Args: 97 Args:
98 pid_tid: ((int, int) PID and TID. 98 pid: (int or None) Selects events from this PID.
99 99 tid: (int or None) Selects events from this TID.
100 Returns: 100 categories: (set([str]) or None) Selects events belonging to one of the
101 A new instance of TracingTrack. 101 categories.
102 """ 102 """
103 (pid, tid) = pid_tid 103 events = self._events
104 events = [e for e in self._events 104 if pid is not None:
105 if (e.tracing_event['pid'] == pid 105 events = filter(lambda e : e.tracing_event['pid'] == pid, events)
106 and e.tracing_event['tid'] == tid)] 106 if tid is not None:
107 events = filter(lambda e : e.tracing_event['tid'] == tid, events)
108 if categories is not None:
109 events = filter(
110 lambda e : set(e.category.split(',')).intersection(categories),
111 events)
107 tracing_track = TracingTrack(None) 112 tracing_track = TracingTrack(None)
108 tracing_track._events = events 113 tracing_track._events = events
109 return tracing_track 114 return tracing_track
110 115
111 @classmethod 116 @classmethod
112 def FromJsonDict(cls, json_dict): 117 def FromJsonDict(cls, json_dict):
113 assert 'events' in json_dict 118 assert 'events' in json_dict
114 events = [Event(e) for e in json_dict['events']] 119 events = [Event(e) for e in json_dict['events']]
115 tracing_track = TracingTrack(None) 120 tracing_track = TracingTrack(None)
116 tracing_track._events = events 121 tracing_track._events = events
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 self._left = _IntervalTree(self.start, left_end, left_events) 494 self._left = _IntervalTree(self.start, left_end, left_events)
490 self._right = _IntervalTree(right_start, self.end, right_events) 495 self._right = _IntervalTree(right_start, self.end, right_events)
491 496
492 def _IsLeaf(self): 497 def _IsLeaf(self):
493 return self._left is None 498 return self._left is None
494 499
495 @classmethod 500 @classmethod
496 def _Overlaps(cls, event, start, end): 501 def _Overlaps(cls, event, start, end):
497 return (min(end, event.end_msec) - max(start, event.start_msec) > 0 502 return (min(end, event.end_msec) - max(start, event.start_msec) > 0
498 or start <= event.start_msec < end) # For instant events. 503 or start <= event.start_msec < end) # For instant events.
OLDNEW
« no previous file with comments | « tools/android/loading/test_utils.py ('k') | tools/android/loading/tracing_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698