OLD | NEW |
---|---|
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 |
11 | 11 |
12 import devtools_monitor | 12 import devtools_monitor |
13 | 13 |
14 | 14 |
15 DEFAULT_CATEGORIES = None | |
16 | |
17 | |
15 class TracingTrack(devtools_monitor.Track): | 18 class TracingTrack(devtools_monitor.Track): |
16 """Grabs and processes trace event messages. | 19 """Grabs and processes trace event messages. |
17 | 20 |
18 See https://goo.gl/Qabkqk for details on the protocol. | 21 See https://goo.gl/Qabkqk for details on the protocol. |
19 """ | 22 """ |
20 def __init__(self, connection, categories=None, fetch_stream=False): | 23 def __init__(self, connection, |
24 categories=DEFAULT_CATEGORIES, | |
25 fetch_stream=False): | |
21 """Initialize this TracingTrack. | 26 """Initialize this TracingTrack. |
22 | 27 |
23 Args: | 28 Args: |
24 connection: a DevToolsConnection. | 29 connection: a DevToolsConnection. |
25 categories: None, or a string, or list of strings, of tracing categories | 30 categories: None, or a string, or list of strings, of tracing categories |
26 to filter. | 31 to filter. |
27 | 32 |
28 fetch_stream: if true, use a websocket stream to fetch tracing data rather | 33 fetch_stream: if true, use a websocket stream to fetch tracing data rather |
29 than dataCollected events. It appears based on very limited testing that | 34 than dataCollected events. It appears based on very limited testing that |
30 a stream is slower than the default reporting as dataCollected events. | 35 a stream is slower than the default reporting as dataCollected events. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 if 'dur' in tracing_event else tracing_event['tdur']) | 302 if 'dur' in tracing_event else tracing_event['tdur']) |
298 self.end_msec = self.start_msec + duration / 1000.0 | 303 self.end_msec = self.start_msec + duration / 1000.0 |
299 | 304 |
300 @property | 305 @property |
301 def type(self): | 306 def type(self): |
302 if self._synthetic: | 307 if self._synthetic: |
303 return None | 308 return None |
304 return self._tracing_event['ph'] | 309 return self._tracing_event['ph'] |
305 | 310 |
306 @property | 311 @property |
312 def category(self): | |
313 return self._tracing_event['cat'] | |
314 | |
315 @property | |
316 def name(self): | |
Benoit L
2016/02/22 10:26:13
Notice: Rebase before landing, as I believe that t
gabadie
2016/02/22 11:05:06
Done.
| |
317 return self._tracing_event['name'] | |
318 | |
319 @property | |
320 def pid(self): | |
321 return self._tracing_event['pid'] | |
322 | |
323 @property | |
307 def args(self): | 324 def args(self): |
308 return self._tracing_event.get('args', {}) | 325 return self._tracing_event.get('args', {}) |
309 | 326 |
310 @property | 327 @property |
311 def id(self): | 328 def id(self): |
312 return self._tracing_event.get('id') | 329 return self._tracing_event.get('id') |
313 | 330 |
314 @property | 331 @property |
315 def tracing_event(self): | 332 def tracing_event(self): |
316 return self._tracing_event | 333 return self._tracing_event |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 self._left = _IntervalTree(self.start, left_end, left_events) | 467 self._left = _IntervalTree(self.start, left_end, left_events) |
451 self._right = _IntervalTree(right_start, self.end, right_events) | 468 self._right = _IntervalTree(right_start, self.end, right_events) |
452 | 469 |
453 def _IsLeaf(self): | 470 def _IsLeaf(self): |
454 return self._left is None | 471 return self._left is None |
455 | 472 |
456 @classmethod | 473 @classmethod |
457 def _Overlaps(cls, event, start, end): | 474 def _Overlaps(cls, event, start, end): |
458 return (min(end, event.end_msec) - max(start, event.start_msec) > 0 | 475 return (min(end, event.end_msec) - max(start, event.start_msec) > 0 |
459 or start <= event.start_msec < end) # For instant events. | 476 or start <= event.start_msec < end) # For instant events. |
OLD | NEW |