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

Side by Side Diff: tools/android/customtabs_benchmark/scripts/customtabs_benchmark.py

Issue 2375113002: tools: Log time to first contentful paint in customtabs_benchmark. (Closed)
Patch Set: Created 4 years, 2 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/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Loops Custom Tabs tests and outputs the results into a CSV file.""" 7 """Loops Custom Tabs tests and outputs the results into a CSV file."""
8 8
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 device: (DeviceUtils) device to run the tests on. 71 device: (DeviceUtils) device to run the tests on.
72 warmup: (bool) Whether to call warmup. 72 warmup: (bool) Whether to call warmup.
73 prerender_mode: (str) Prerender mode (disabled, enabled or prefetch). 73 prerender_mode: (str) Prerender mode (disabled, enabled or prefetch).
74 delay_to_may_launch_url: (int) Delay to mayLaunchUrl() in ms. 74 delay_to_may_launch_url: (int) Delay to mayLaunchUrl() in ms.
75 delay_to_launch_url: (int) Delay to launchUrl() in ms. 75 delay_to_launch_url: (int) Delay to launchUrl() in ms.
76 cold: (bool) Whether the page cache should be dropped. 76 cold: (bool) Whether the page cache should be dropped.
77 77
78 Returns: 78 Returns:
79 The output line (str), like this (one line only): 79 The output line (str), like this (one line only):
80 <warmup>,<prerender_mode>,<delay_to_may_launch_url>,<delay_to_launch>, 80 <warmup>,<prerender_mode>,<delay_to_may_launch_url>,<delay_to_launch>,
81 <intent_sent_ms>,<page_load_started_ms>,<page_load_finished_ms> 81 <intent_sent_ms>,<page_load_started_ms>,<page_load_finished_ms>,
82 <first_contentful_paint>
82 or None on error. 83 or None on error.
83 """ 84 """
84 launch_intent = intent.Intent( 85 launch_intent = intent.Intent(
85 action='android.intent.action.MAIN', 86 action='android.intent.action.MAIN',
86 package='org.chromium.customtabsclient.test', 87 package='org.chromium.customtabsclient.test',
87 activity='org.chromium.customtabs.test.MainActivity', 88 activity='org.chromium.customtabs.test.MainActivity',
88 extras={'url': url, 'warmup': warmup, 'prerender_mode': prerender_mode, 89 extras={'url': url, 'warmup': warmup, 'prerender_mode': prerender_mode,
89 'delay_to_may_launch_url': delay_to_may_launch_url, 90 'delay_to_may_launch_url': delay_to_may_launch_url,
90 'delay_to_launch_url': delay_to_launch_url}) 91 'delay_to_launch_url': delay_to_launch_url})
91 result_line_re = re.compile(r'CUSTOMTABSBENCH.*: (.*)') 92 result_line_re = re.compile(r'CUSTOMTABSBENCH.*: (.*)')
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 148
148 Returns: 149 Returns:
149 A numpy structured array. 150 A numpy structured array.
150 """ 151 """
151 import numpy as np 152 import numpy as np
152 data = np.genfromtxt(filename, delimiter=',') 153 data = np.genfromtxt(filename, delimiter=',')
153 result = np.array(np.zeros(len(data)), 154 result = np.array(np.zeros(len(data)),
154 dtype=[('warmup', bool), ('prerender_mode', np.int32), 155 dtype=[('warmup', bool), ('prerender_mode', np.int32),
155 ('delay_to_may_launch_url', np.int32), 156 ('delay_to_may_launch_url', np.int32),
156 ('delay_to_launch_url', np.int32), 157 ('delay_to_launch_url', np.int32),
157 ('commit', np.int32), ('plt', np.int32)]) 158 ('commit', np.int32), ('plt', np.int32),
159 ('first_contentful_paint', np.int32)])
158 result['warmup'] = data[:, 0] 160 result['warmup'] = data[:, 0]
159 result['prerender_mode'] = data[:, 1] 161 result['prerender_mode'] = data[:, 1]
160 result['delay_to_may_launch_url'] = data[:, 2] 162 result['delay_to_may_launch_url'] = data[:, 2]
161 result['delay_to_launch_url'] = data[:, 3] 163 result['delay_to_launch_url'] = data[:, 3]
162 result['commit'] = data[:, 5] - data[:, 4] 164 result['commit'] = data[:, 5] - data[:, 4]
163 result['plt'] = data[:, 6] - data[:, 4] 165 result['plt'] = data[:, 6] - data[:, 4]
166 result['first_contentful_paint'] = data[7]
164 return result 167 return result
165 168
166 169
167 def _CreateOptionParser(): 170 def _CreateOptionParser():
168 parser = optparse.OptionParser(description='Loops Custom Tabs tests on a ' 171 parser = optparse.OptionParser(description='Loops Custom Tabs tests on a '
169 'device, and outputs the navigation timings ' 172 'device, and outputs the navigation timings '
170 'in a CSV file.') 173 'in a CSV file.')
171 parser.add_option('--device', help='Device ID') 174 parser.add_option('--device', help='Device ID')
172 parser.add_option('--url', help='URL to navigate to.', 175 parser.add_option('--url', help='URL to navigate to.',
173 default='https://www.android.com') 176 default='https://www.android.com')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 device, '/data/local/tmp/chrome-command-line', 214 device, '/data/local/tmp/chrome-command-line',
212 _CHROME_ARGS + ['--prerender=' + options.prerender_mode]): 215 _CHROME_ARGS + ['--prerender=' + options.prerender_mode]):
213 LoopOnDevice(device, options.url, options.warmup, 216 LoopOnDevice(device, options.url, options.warmup,
214 options.prerender_mode, 217 options.prerender_mode,
215 options.delay_to_may_launch_url, options.delay_to_launch_url, 218 options.delay_to_may_launch_url, options.delay_to_launch_url,
216 options.cold, options.output_file, options.once) 219 options.cold, options.output_file, options.once)
217 220
218 221
219 if __name__ == '__main__': 222 if __name__ == '__main__':
220 main() 223 main()
OLDNEW
« no previous file with comments | « tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698