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

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

Issue 2763733002: tools/android/loading: rename tracing to tracing_track (Closed)
Patch Set: also rename the unittest Created 3 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
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 """Pull a sandwich run's output directory's metrics from traces into a CSV. 5 """Pull a sandwich run's output directory's metrics from traces into a CSV.
6 6
7 python pull_sandwich_metrics.py -h 7 python pull_sandwich_metrics.py -h
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 12 matching lines...) Expand all
23 from chrome_telemetry_build import chromium_config 23 from chrome_telemetry_build import chromium_config
24 24
25 sys.path.append(chromium_config.GetTelemetryDir()) 25 sys.path.append(chromium_config.GetTelemetryDir())
26 from telemetry.internal.image_processing import video 26 from telemetry.internal.image_processing import video
27 from telemetry.util import image_util 27 from telemetry.util import image_util
28 from telemetry.util import rgba_color 28 from telemetry.util import rgba_color
29 29
30 import common_util 30 import common_util
31 import loading_trace as loading_trace_module 31 import loading_trace as loading_trace_module
32 import sandwich_runner 32 import sandwich_runner
33 import tracing 33 import tracing_track
34 34
35 35
36 COMMON_CSV_COLUMN_NAMES = [ 36 COMMON_CSV_COLUMN_NAMES = [
37 'chromium_commit', 37 'chromium_commit',
38 'platform', 38 'platform',
39 'first_layout', 39 'first_layout',
40 'first_contentful_paint', 40 'first_contentful_paint',
41 'first_meaningful_paint', 41 'first_meaningful_paint',
42 'total_load', 42 'total_load',
43 'js_onload_event', 43 'js_onload_event',
(...skipping 19 matching lines...) Expand all
63 # Points of a completeness record. 63 # Points of a completeness record.
64 # 64 #
65 # Members: 65 # Members:
66 # |time| is in milliseconds, 66 # |time| is in milliseconds,
67 # |frame_completeness| value representing how complete the frame is at a given 67 # |frame_completeness| value representing how complete the frame is at a given
68 # |time|. Caution: this completeness might be negative. 68 # |time|. Caution: this completeness might be negative.
69 CompletenessPoint = collections.namedtuple('CompletenessPoint', 69 CompletenessPoint = collections.namedtuple('CompletenessPoint',
70 ('time', 'frame_completeness')) 70 ('time', 'frame_completeness'))
71 71
72 72
73 def _GetBrowserPID(tracing_track): 73 def _GetBrowserPID(track):
74 """Get the browser PID from a trace. 74 """Get the browser PID from a trace.
75 75
76 Args: 76 Args:
77 tracing_track: The tracing.TracingTrack. 77 track: The tracing_track.TracingTrack.
78 78
79 Returns: 79 Returns:
80 The browser's PID as an integer. 80 The browser's PID as an integer.
81 """ 81 """
82 for event in tracing_track.GetEvents(): 82 for event in track.GetEvents():
83 if event.category != '__metadata' or event.name != 'process_name': 83 if event.category != '__metadata' or event.name != 'process_name':
84 continue 84 continue
85 if event.args['name'] == 'Browser': 85 if event.args['name'] == 'Browser':
86 return event.pid 86 return event.pid
87 raise ValueError('couldn\'t find browser\'s PID') 87 raise ValueError('couldn\'t find browser\'s PID')
88 88
89 89
90 def _GetBrowserDumpEvents(tracing_track): 90 def _GetBrowserDumpEvents(track):
91 """Get the browser memory dump events from a tracing track. 91 """Get the browser memory dump events from a tracing track.
92 92
93 Args: 93 Args:
94 tracing_track: The tracing.TracingTrack. 94 track: The tracing_track.TracingTrack.
95 95
96 Returns: 96 Returns:
97 List of memory dump events. 97 List of memory dump events.
98 """ 98 """
99 assert sandwich_runner.MEMORY_DUMP_CATEGORY in tracing_track.Categories() 99 assert sandwich_runner.MEMORY_DUMP_CATEGORY in track.Categories()
100 browser_pid = _GetBrowserPID(tracing_track) 100 browser_pid = _GetBrowserPID(track)
101 browser_dumps_events = [] 101 browser_dumps_events = []
102 for event in tracing_track.GetEvents(): 102 for event in track.GetEvents():
103 if event.category != 'disabled-by-default-memory-infra': 103 if event.category != 'disabled-by-default-memory-infra':
104 continue 104 continue
105 if event.type != 'v' or event.name != 'periodic_interval': 105 if event.type != 'v' or event.name != 'periodic_interval':
106 continue 106 continue
107 # Ignore dump events for processes other than the browser process 107 # Ignore dump events for processes other than the browser process
108 if event.pid != browser_pid: 108 if event.pid != browser_pid:
109 continue 109 continue
110 browser_dumps_events.append(event) 110 browser_dumps_events.append(event)
111 if len(browser_dumps_events) == 0: 111 if len(browser_dumps_events) == 0:
112 raise ValueError('No browser dump events found.') 112 raise ValueError('No browser dump events found.')
113 return browser_dumps_events 113 return browser_dumps_events
114 114
115 115
116 def _GetWebPageTrackedEvents(tracing_track): 116 def _GetWebPageTrackedEvents(track):
117 """Get the web page's tracked events from a tracing track. 117 """Get the web page's tracked events from a tracing track.
118 118
119 Args: 119 Args:
120 tracing_track: The tracing.TracingTrack. 120 track: The tracing_track.TracingTrack.
121 121
122 Returns: 122 Returns:
123 A dict mapping event.name -> tracing.Event for each first occurrence of a 123 A dict mapping event.name -> tracing_track.Event for each first occurrence
124 tracked event. 124 of a tracked event.
125 """ 125 """
126 main_frame_id = None 126 main_frame_id = None
127 tracked_events = {} 127 tracked_events = {}
128 sorted_events = sorted(tracing_track.GetEvents(), 128 sorted_events = sorted(track.GetEvents(),
129 key=lambda event: event.start_msec) 129 key=lambda event: event.start_msec)
130 for event in sorted_events: 130 for event in sorted_events:
131 if event.category != 'blink.user_timing': 131 if event.category != 'blink.user_timing':
132 continue 132 continue
133 event_name = event.name 133 event_name = event.name
134 134
135 # Find the id of the main frame. Skip all events until it is found. 135 # Find the id of the main frame. Skip all events until it is found.
136 if not main_frame_id: 136 if not main_frame_id:
137 # Tracing (in Sandwich) is started after about:blank is fully loaded, 137 # Tracing (in Sandwich) is started after about:blank is fully loaded,
138 # hence the first navigationStart in the trace registers the correct frame 138 # hence the first navigationStart in the trace registers the correct frame
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 except video.BoundingBoxNotFoundException: 336 except video.BoundingBoxNotFoundException:
337 # Sometimes the bounding box for the web content area is not present. Skip 337 # Sometimes the bounding box for the web content area is not present. Skip
338 # calculating Speed Index. 338 # calculating Speed Index.
339 run_metrics['speed_index'] = _FAILED_CSV_VALUE 339 run_metrics['speed_index'] = _FAILED_CSV_VALUE
340 else: 340 else:
341 run_metrics['speed_index'] = _UNAVAILABLE_CSV_VALUE 341 run_metrics['speed_index'] = _UNAVAILABLE_CSV_VALUE
342 for key, value in trace.metadata['network_emulation'].iteritems(): 342 for key, value in trace.metadata['network_emulation'].iteritems():
343 run_metrics['net_emul.' + key] = value 343 run_metrics['net_emul.' + key] = value
344 assert set(run_metrics.keys()) == set(COMMON_CSV_COLUMN_NAMES) 344 assert set(run_metrics.keys()) == set(COMMON_CSV_COLUMN_NAMES)
345 return run_metrics 345 return run_metrics
OLDNEW
« no previous file with comments | « tools/android/loading/loading_trace.py ('k') | tools/android/loading/sandwich_metrics_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698