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

Side by Side Diff: mojo/devtools/common/devtoolslib/perf_dashboard.py

Issue 1417553008: Cleanup the benchmarking script. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | mojo/devtools/common/mojo_benchmark » ('j') | mojo/devtools/common/mojo_benchmark » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 # Disable the line-too-long warning. 5 # Disable the line-too-long warning.
6 # pylint: disable=C0301 6 # pylint: disable=C0301
7 """This module implements the Chromium Performance Dashboard JSON v1.0 data 7 """This module implements the Chromium Performance Dashboard JSON v1.0 data
8 format. 8 format.
9 9
10 See http://www.chromium.org/developers/speed-infra/performance-dashboard/sending -data-to-the-performance-dashboard. 10 See http://www.chromium.org/developers/speed-infra/performance-dashboard/sending -data-to-the-performance-dashboard.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 Returns: 101 Returns:
102 Normalized label. 102 Normalized label.
103 """ 103 """
104 return label.replace('/', '-').replace(' ', '_') 104 return label.replace('/', '-').replace(' ', '_')
105 105
106 106
107 def _get_commit_count(): 107 def _get_commit_count():
108 """Returns the number of git commits in the repository of the cwd.""" 108 """Returns the number of git commits in the repository of the cwd."""
109 return subprocess.check_output( 109 return subprocess.check_output(
110 ["git", "rev-list", "HEAD", "--count"]).strip() 110 ['git', 'rev-list', 'HEAD', '--count']).strip()
111 111
112 112
113 def _get_current_commit(): 113 def _get_current_commit():
114 """Returns the hash of the current commit in the repository of the cwd.""" 114 """Returns the hash of the current commit in the repository of the cwd."""
115 return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip() 115 return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
116 116
117 117
118 def upload_chart_data(master_name, bot_name, test_name, builder_name, 118 def upload_chart_data(master_name, bot_name, test_name, builder_name,
119 build_number, chart_data, server_url=None, dry_run=False): 119 build_number, chart_data, server_url=None, dry_run=False):
120 """Uploads the provided chart data to an instance of performance dashboard. 120 """Uploads the provided chart data to an instance of performance dashboard.
(...skipping 16 matching lines...) Expand all
137 Raises: 137 Raises:
138 _UploadException: An error occurred during uploading. 138 _UploadException: An error occurred during uploading.
139 """ 139 """
140 # When data is provided to urllib2.Request, a POST is sent instead of GET. 140 # When data is provided to urllib2.Request, a POST is sent instead of GET.
141 # The data must be in the application/x-www-form-urlencoded format. 141 # The data must be in the application/x-www-form-urlencoded format.
142 data = urllib.urlencode({"data": json_data}) 142 data = urllib.urlencode({"data": json_data})
143 req = urllib2.Request("%s/add_point" % server_url, data) 143 req = urllib2.Request("%s/add_point" % server_url, data)
144 try: 144 try:
145 urllib2.urlopen(req) 145 urllib2.urlopen(req)
146 except urllib2.HTTPError as e: 146 except urllib2.HTTPError as e:
147 raise _UploadException("HTTPError: %d. Response: %s\n" 147 raise _UploadException('HTTPError: %d. Response: %s\n'
148 "JSON: %s\n" % (e.code, e.read(), json_data)) 148 'JSON: %s\n' % (e.code, e.read(), json_data))
149 except urllib2.URLError as e: 149 except urllib2.URLError as e:
150 raise _UploadException("URLError: %s for JSON %s\n" % 150 raise _UploadException('URLError: %s for JSON %s\n' %
151 (str(e.reason), json_data)) 151 (str(e.reason), json_data))
152 except httplib.HTTPException as e: 152 except httplib.HTTPException as e:
153 raise _UploadException("HTTPException for JSON %s\n" % json_data) 153 raise _UploadException('HTTPException for JSON %s\n' % json_data)
154 154
155 if (not master_name or not bot_name or not test_name or not builder_name or 155 if (not master_name or not bot_name or not test_name or not builder_name or
156 not build_number): 156 not build_number):
157 print ('Cannot upload perf data to the dashboard because not all of the ' 157 print ('Cannot upload perf data to the dashboard because not all of the '
158 'following values are specified: master-name, bot-name, test_name, ' 158 'following values are specified: master-name, bot-name, test_name, '
159 'builder-name, build-number.') 159 'builder-name, build-number.')
160 return False 160 return False
161 161
162 point_id = _get_commit_count() 162 point_id = _get_commit_count()
163 cur_commit = _get_current_commit() 163 cur_commit = _get_current_commit()
164 164
165 # Wrap the |chart_data| with meta data as required by the spec. 165 # Wrap the |chart_data| with meta data as required by the spec.
166 formatted_data = { 166 formatted_data = {
167 "master": master_name, 167 'master': master_name,
168 "bot": bot_name, 168 'bot': bot_name,
169 "masterid": master_name, 169 'masterid': master_name,
170 "buildername": builder_name, 170 'buildername': builder_name,
171 "buildnumber": build_number, 171 'buildnumber': build_number,
172 "versions": { 172 'versions': {
173 "mojo": cur_commit, 173 'mojo': cur_commit,
174 }, 174 },
175 "point_id": point_id, 175 'point_id': point_id,
176 "supplemental": {}, 176 'supplemental': {},
177 "chart_data": chart_data, 177 'chart_data': chart_data,
178 } 178 }
179 179
180 upload_url = server_url if server_url else _LOCAL_SERVER 180 upload_url = server_url if server_url else _LOCAL_SERVER
181 181
182 if dry_run: 182 if dry_run:
183 print "Won't upload because --dry-run is specified." 183 print 'Will not upload because --dry-run is specified.'
184 print "Server: %s" % upload_url 184 print 'Server: %s' % upload_url
185 print "Data:" 185 print 'Data:'
186 pprint.pprint(formatted_data) 186 pprint.pprint(formatted_data)
187 else: 187 else:
188 print "Uploading data to %s ..." % upload_url 188 print 'Uploading data to %s ...' % upload_url
189 try: 189 try:
190 _upload(upload_url, json.dumps(formatted_data)) 190 _upload(upload_url, json.dumps(formatted_data))
191 except _UploadException as e: 191 except _UploadException as e:
192 print e 192 print e
193 return False 193 return False
194 194
195 print "Done." 195 print "Done."
196 196
197 dashboard_params = urllib.urlencode({ 197 dashboard_params = urllib.urlencode({
198 "masters": master_name, 198 'masters': master_name,
199 "bots": bot_name, 199 'bots': bot_name,
200 "tests": test_name, 200 'tests': test_name,
201 "rev": point_id 201 'rev': point_id
202 }) 202 })
203 print "Results Dashboard: %s/report?%s" % (upload_url, dashboard_params) 203 print 'Results Dashboard: %s/report?%s' % (upload_url, dashboard_params)
204 204
205 return True 205 return True
OLDNEW
« no previous file with comments | « no previous file | mojo/devtools/common/mojo_benchmark » ('j') | mojo/devtools/common/mojo_benchmark » ('J')

Powered by Google App Engine
This is Rietveld 408576698