| 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 |
| 3 |
# found in the LICENSE file. |
| 4 |
|
| 5 |
|
| 6 |
# Recipe module for Skia Swarming perf. |
| 7 |
|
| 8 |
|
| 9 |
import calendar |
| 10 |
import json |
| 11 |
import os |
| 12 |
|
| 13 |
|
| 14 |
DEPS = [ |
| 15 |
'env', |
| 16 |
'flavor', |
| 17 |
'recipe_engine/file', |
| 18 |
'recipe_engine/json', |
| 19 |
'recipe_engine/path', |
| 20 |
'recipe_engine/platform', |
| 21 |
'recipe_engine/properties', |
| 22 |
'recipe_engine/raw_io', |
| 23 |
'recipe_engine/step', |
| 24 |
'recipe_engine/time', |
| 25 |
'run', |
| 26 |
'vars', |
| 27 |
] |
| 28 |
|
| 29 |
|
| 30 |
def perf_steps(api): |
| 31 |
"""Run Skia benchmarks.""" |
| 32 |
do_upload = api.properties.get('do_upload') == 'true' |
| 33 |
images = api.properties.get('images') == 'true' |
| 34 |
resources = api.properties.get('resources') == 'true' |
| 35 |
skps = api.properties.get('skps') == 'true' |
| 36 |
svgs = api.properties.get('svgs') == 'true' |
| 37 |
texttraces = api.properties.get('texttraces') == 'true' |
| 38 |
|
| 39 |
api.flavor.install( |
| 40 |
resources=resources, |
| 41 |
skps=skps, |
| 42 |
images=images, |
| 43 |
svgs=svgs, |
| 44 |
texttraces=texttraces, |
| 45 |
) |
| 46 |
|
| 47 |
if do_upload: |
| 48 |
api.flavor.create_clean_device_dir( |
| 49 |
api.flavor.device_dirs.perf_data_dir) |
| 50 |
|
| 51 |
# Find nanobench flags. |
| 52 |
args = json.loads(api.properties['nanobench_flags']) |
| 53 |
props = json.loads(api.properties['nanobench_properties']) |
| 54 |
swarming_bot_id = api.vars.swarming_bot_id |
| 55 |
swarming_task_id = api.vars.swarming_task_id |
| 56 |
if do_upload: |
| 57 |
args.append('--properties') |
| 58 |
# Map iteration order is arbitrary; in order to maintain a consistent step |
| 59 |
# ordering, sort by key. |
| 60 |
for k in sorted(props.keys()): |
| 61 |
v = props[k] |
| 62 |
if v == '${SWARMING_BOT_ID}': |
| 63 |
v = swarming_bot_id |
| 64 |
elif v == '${SWARMING_TASK_ID}': |
| 65 |
v = swarming_task_id |
| 66 |
if v != '': |
| 67 |
args.extend([k, v]) |
| 68 |
|
| 69 |
# Paths to required resources. |
| 70 |
if resources: |
| 71 |
args.extend(['-i', api.flavor.device_dirs.resource_dir]) |
| 72 |
if skps: |
| 73 |
args.extend(['--skps', api.flavor.device_dirs.skp_dir]), |
| 74 |
if images: |
| 75 |
args.extend(['--images', api.flavor.device_path_join( |
| 76 |
api.flavor.device_dirs.images_dir, 'nanobench')]) |
| 77 |
if texttraces: |
| 78 |
assert api.flavor.device_dirs.texttraces_dir |
| 79 |
args.extend(['--texttraces', api.flavor.device_dirs.texttraces_dir]) |
| 80 |
if svgs: |
| 81 |
args.extend(['--svgs', api.flavor.device_dirs.svg_dir]) |
| 82 |
if do_upload: |
| 83 |
now = api.time.utcnow() |
| 84 |
ts = int(calendar.timegm(now.utctimetuple())) |
| 85 |
json_path = api.flavor.device_path_join( |
| 86 |
api.flavor.device_dirs.perf_data_dir, |
| 87 |
'nanobench_%s_%d.json' % (api.properties['revision'], ts)) |
| 88 |
args.extend(['--outResultsFile', json_path]) |
| 89 |
|
| 90 |
api.run(api.flavor.step, 'nanobench', cmd=args, |
| 91 |
abort_on_failure=False) |
| 92 |
|
| 93 |
# Copy results to swarming out dir. |
| 94 |
if do_upload: |
| 95 |
api.file.ensure_directory( |
| 96 |
'makedirs perf_dir', |
| 97 |
api.flavor.host_dirs.perf_data_dir) |
| 98 |
api.flavor.copy_directory_contents_to_host( |
| 99 |
api.flavor.device_dirs.perf_data_dir, |
| 100 |
api.flavor.host_dirs.perf_data_dir) |
| 101 |
|
| 102 |
|
| 103 |
def RunSteps(api): |
| 104 |
api.vars.setup() |
| 105 |
api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) |
| 106 |
api.flavor.setup('nanobench') |
| 107 |
|
| 108 |
try: |
| 109 |
perf_steps(api) |
| 110 |
finally: |
| 111 |
api.flavor.cleanup_steps() |
| 112 |
api.run.check_failure() |
| 113 |
|
| 114 |
|
| 115 |
TEST_BUILDERS = [ |
| 116 |
'Perf-Android-Clang-Nexus7-CPU-Tegra3-arm-Debug-All-Android', |
| 117 |
'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-ANGLE', |
| 118 |
] |
| 119 |
|
| 120 |
|
| 121 |
def GenTests(api): |
| 122 |
for builder in TEST_BUILDERS: |
| 123 |
props = dict( |
| 124 |
buildername=builder, |
| 125 |
nanobench_flags='["nanobench","--example","--flags"]', |
| 126 |
nanobench_properties=('{"key1":"value1","key2":"",' |
| 127 |
'"bot":"${SWARMING_BOT_ID}",' |
| 128 |
'"task":"${SWARMING_TASK_ID}"}'), |
| 129 |
path_config='kitchen', |
| 130 |
resources='true', |
| 131 |
revision='abc123', |
| 132 |
swarm_out_dir='[SWARM_OUT_DIR]' |
| 133 |
) |
| 134 |
props['svgs'] = 'true' |
| 135 |
if 'Debug' not in builder: |
| 136 |
props['do_upload'] = 'true' |
| 137 |
if 'GPU' not in builder: |
| 138 |
props['images'] = 'true' |
| 139 |
if 'iOS' not in builder: |
| 140 |
props['skps'] = 'true' |
| 141 |
if 'Android' in builder and 'CPU' in builder: |
| 142 |
props['texttraces'] = 'true' |
| 143 |
test = ( |
| 144 |
api.test(builder) + |
| 145 |
api.properties(**props) + |
| 146 |
api.path.exists( |
| 147 |
api.path.start_dir.joinpath('skia'), |
| 148 |
api.path.start_dir.joinpath('skia', 'infra', 'bots', 'assets', |
| 149 |
'skimage', 'VERSION'), |
| 150 |
api.path.start_dir.joinpath('skia', 'infra', 'bots', 'assets', |
| 151 |
'skp', 'VERSION'), |
| 152 |
) + |
| 153 |
api.step_data('get swarming bot id', |
| 154 |
stdout=api.raw_io.output('skia-bot-123')) + |
| 155 |
api.step_data('get swarming task id', |
| 156 |
stdout=api.raw_io.output('123456')) |
| 157 |
) |
| 158 |
if 'Win' in builder: |
| 159 |
test += api.platform('win', 64) |
| 160 |
|
| 161 |
yield test |