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 """Gives a picture of the CPU activity between timestamps. | 5 """Gives a picture of the CPU activity between timestamps. |
6 | 6 |
7 When executed as a script, takes a loading trace, and prints the activity | 7 When executed as a script, takes a loading trace, and prints the activity |
8 breakdown for the request dependencies. | 8 breakdown for the request dependencies. |
9 """ | 9 """ |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 def __init__(self, trace): | 23 def __init__(self, trace): |
24 """Initializes an instance of ActivityLens. | 24 """Initializes an instance of ActivityLens. |
25 | 25 |
26 Args: | 26 Args: |
27 trace: (LoadingTrace) loading trace. | 27 trace: (LoadingTrace) loading trace. |
28 """ | 28 """ |
29 self._trace = trace | 29 self._trace = trace |
30 events = trace.tracing_track.GetEvents() | 30 events = trace.tracing_track.GetEvents() |
31 self._renderer_main_pid_tid = self._GetRendererMainThreadId(events) | 31 self._renderer_main_pid_tid = self._GetRendererMainThreadId(events) |
32 self._tracing = self._trace.tracing_track.TracingTrackForThread( | 32 self._tracing = self._trace.tracing_track.Filter( |
33 self._renderer_main_pid_tid) | 33 *self._renderer_main_pid_tid) |
34 | 34 |
35 @classmethod | 35 @classmethod |
36 def _GetRendererMainThreadId(cls, events): | 36 def _GetRendererMainThreadId(cls, events): |
37 """Returns the most active main renderer thread. | 37 """Returns the most active main renderer thread. |
38 | 38 |
39 Several renderers may be running concurrently, but we assume that only one | 39 Several renderers may be running concurrently, but we assume that only one |
40 of them is busy during the time covered by the loading trace.. It can be | 40 of them is busy during the time covered by the loading trace.. It can be |
41 selected by looking at the number of trace events generated. | 41 selected by looking at the number of trace events generated. |
42 | 42 |
43 Args: | 43 Args: |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 filename = sys.argv[1] | 276 filename = sys.argv[1] |
277 json_dict = json.load(open(filename)) | 277 json_dict = json.load(open(filename)) |
278 loading_trace = loading_trace.LoadingTrace.FromJsonDict(json_dict) | 278 loading_trace = loading_trace.LoadingTrace.FromJsonDict(json_dict) |
279 activity_lens = ActivityLens(loading_trace) | 279 activity_lens = ActivityLens(loading_trace) |
280 dependencies_lens = request_dependencies_lens.RequestDependencyLens( | 280 dependencies_lens = request_dependencies_lens.RequestDependencyLens( |
281 loading_trace) | 281 loading_trace) |
282 deps = dependencies_lens.GetRequestDependencies() | 282 deps = dependencies_lens.GetRequestDependencies() |
283 for requests_dep in deps: | 283 for requests_dep in deps: |
284 print activity_lens.GenerateEdgeActivity(requests_dep) | 284 print activity_lens.GenerateEdgeActivity(requests_dep) |
OLD | NEW |