Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 1 | # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | |
| 6 | # Recipe for uploading calmbench results. |
| 7 | |
| 8 | |
| 9 | import calendar |
| 10 | |
| 11 | |
| 12 | DEPS = [ |
Eric Boren | b702316 | 2018-05-04 13:46:15 -0400 | [diff] [blame] | 13 | 'flavor', |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 14 | 'recipe_engine/context', |
| 15 | 'recipe_engine/file', |
| 16 | 'recipe_engine/path', |
| 17 | 'recipe_engine/properties', |
| 18 | 'recipe_engine/step', |
| 19 | 'recipe_engine/time', |
Eric Boren | b702316 | 2018-05-04 13:46:15 -0400 | [diff] [blame] | 20 | 'run', |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 21 | 'vars', |
| 22 | ] |
| 23 | |
| 24 | |
| 25 | def FindFile(api, suffix): |
| 26 | with api.context(cwd=api.path['start_dir']): |
| 27 | results = api.file.glob_paths( |
| 28 | 'find %s results' % suffix, |
Eric Boren | 72f6668 | 2018-05-18 07:36:55 -0400 | [diff] [blame] | 29 | api.path['start_dir'].join('perf'), |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 30 | '*.%s' % suffix, |
| 31 | test_data=['bench_modified_master.%s' % suffix]) |
| 32 | if len(results) != 1: # pragma: nocover |
| 33 | raise Exception('Unable to find the %s file!' % suffix) |
| 34 | return results[0] |
| 35 | |
| 36 | |
| 37 | def RunSteps(api): |
Eric Boren | b702316 | 2018-05-04 13:46:15 -0400 | [diff] [blame] | 38 | api.vars.setup() |
| 39 | api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) |
| 40 | api.flavor.setup() |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 41 | |
| 42 | builder_name = api.properties['buildername'] |
| 43 | |
| 44 | now = api.time.utcnow() |
| 45 | |
| 46 | json_src = FindFile(api, "json") |
| 47 | csv_src = FindFile(api, "csv") |
| 48 | |
| 49 | ts = int(calendar.timegm(now.utctimetuple())) |
Eric Boren | 72f6668 | 2018-05-18 07:36:55 -0400 | [diff] [blame] | 50 | basename = "bench_modified_master_%s_%d" % (api.properties['revision'], ts) |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 51 | |
| 52 | gs_path = '/'.join(( |
| 53 | 'calmbench-v1', str(now.year).zfill(4), |
| 54 | str(now.month).zfill(2), str(now.day).zfill(2), str(now.hour).zfill(2), |
| 55 | builder_name)) |
| 56 | |
| 57 | issue = api.properties.get('patch_issue') |
| 58 | patchset = api.properties.get('patch_set') |
| 59 | if issue and patchset: |
| 60 | gs_path = '/'.join(('trybot', gs_path, str(issue), str(patchset))) |
| 61 | |
| 62 | dst = '/'.join(( |
| 63 | 'gs://%s' % api.properties['gs_bucket'], gs_path, basename)) |
| 64 | |
| 65 | json_dst = dst + ".json" |
| 66 | csv_dst = dst + ".csv" |
| 67 | |
| 68 | api.step( |
| 69 | 'upload json', |
| 70 | cmd=['gsutil', 'cp', '-z', 'json', json_src, json_dst], |
| 71 | infra_step=True) |
| 72 | api.step( |
| 73 | 'upload csv', |
| 74 | cmd=['gsutil', 'cp', '-z', 'csv', csv_src, csv_dst], |
| 75 | infra_step=True) |
| 76 | |
| 77 | |
| 78 | def GenTests(api): |
Yuqian Li | ab246cb | 2017-11-02 13:48:23 -0400 | [diff] [blame] | 79 | builder = 'Calmbench-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All' |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 80 | yield ( |
| 81 | api.test('normal_bot') + |
| 82 | api.properties(buildername=builder, |
| 83 | repository='https://skia.googlesource.com/skia.git', |
| 84 | gs_bucket='skia-calmbench', |
| 85 | swarm_out_dir='[SWARM_OUT_DIR]', |
| 86 | revision='abc123', |
| 87 | path_config='kitchen') |
| 88 | ) |
| 89 | |
| 90 | yield ( |
| 91 | api.test('trybot') + |
| 92 | api.properties(buildername=builder, |
| 93 | repository='https://skia.googlesource.com/skia.git', |
| 94 | gs_bucket='skia-calmbench', |
| 95 | swarm_out_dir='[SWARM_OUT_DIR]', |
| 96 | revision='abc123', |
| 97 | path_config='kitchen', |
| 98 | patch_storage='gerrit') + |
| 99 | api.properties.tryserver( |
| 100 | buildername=builder, |
| 101 | gerrit_project='skia', |
| 102 | gerrit_url='https://skia-review.googlesource.com/', |
| 103 | ) |
| 104 | ) |