| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """ Upload benchmark performance data results. """ | |
| 7 | |
| 8 import gzip | |
| 9 import os | |
| 10 import os.path | |
| 11 import re | |
| 12 import subprocess | |
| 13 import sys | |
| 14 import tempfile | |
| 15 | |
| 16 from datetime import datetime | |
| 17 | |
| 18 | |
| 19 def _UploadJSONResults(builder_name, build_number, dest_gsbase, gs_subdir, | |
| 20 full_json_path, gzipped=True, gsutil_path='gsutil', | |
| 21 issue_number=None): | |
| 22 now = datetime.utcnow() | |
| 23 gs_json_path = '/'.join((str(now.year).zfill(4), str(now.month).zfill(2), | |
| 24 str(now.day).zfill(2), str(now.hour).zfill(2))) | |
| 25 gs_dir = '/'.join((gs_subdir, gs_json_path, builder_name)) | |
| 26 if builder_name.endswith('-Trybot'): | |
| 27 if not issue_number: | |
| 28 raise Exception('issue_number build property is missing!') | |
| 29 gs_dir = '/'.join(('trybot', gs_dir, build_number, issue_number)) | |
| 30 full_path_to_upload = full_json_path | |
| 31 file_to_upload = os.path.basename(full_path_to_upload) | |
| 32 gzip_args = [] | |
| 33 if gzipped: | |
| 34 gzip_args = ['-z', 'json'] | |
| 35 cmd = ['python', gsutil_path, 'cp', '-a', 'public-read'] | |
| 36 cmd.extend(gzip_args) | |
| 37 cmd.extend([full_path_to_upload, | |
| 38 '/'.join((dest_gsbase, gs_dir, file_to_upload))]) | |
| 39 print ' '.join(cmd) | |
| 40 subprocess.check_call(cmd) | |
| 41 | |
| 42 | |
| 43 def main(builder_name, build_number, perf_data_dir, got_revision, gsutil_path, | |
| 44 issue_number=None): | |
| 45 """Uploads gzipped nanobench JSON data.""" | |
| 46 # Find the nanobench JSON | |
| 47 file_list = os.listdir(perf_data_dir) | |
| 48 RE_FILE_SEARCH = re.compile( | |
| 49 'nanobench_({})_[0-9]+\.json'.format(got_revision)) | |
| 50 nanobench_name = None | |
| 51 | |
| 52 for file_name in file_list: | |
| 53 if RE_FILE_SEARCH.search(file_name): | |
| 54 nanobench_name = file_name | |
| 55 break | |
| 56 | |
| 57 if nanobench_name: | |
| 58 dest_gsbase = 'gs://skia-perf' | |
| 59 nanobench_json_file = os.path.join(perf_data_dir, | |
| 60 nanobench_name) | |
| 61 _UploadJSONResults(builder_name, build_number, dest_gsbase, 'nano-json-v1', | |
| 62 nanobench_json_file, gsutil_path=gsutil_path, | |
| 63 issue_number=issue_number) | |
| 64 | |
| 65 | |
| 66 if __name__ == '__main__': | |
| 67 main(*sys.argv[1:]) | |
| 68 | |
| OLD | NEW |