32 """Run Skia benchmarks."""
33 do_upload = api.properties.get('do_upload') == 'true'
34 images = api.properties.get('images') == 'true'
35 resources = api.properties.get('resources') == 'true'
36 skps = api.properties.get('skps') == 'true'
37 svgs = api.properties.get('svgs') == 'true'
38 texttraces = api.properties.get('texttraces') == 'true'
39
40 api.flavor.install(
41 resources=resources,
42 skps=skps,
43 images=images,
44 svgs=svgs,
45 texttraces=texttraces,
46 )
47
48 if do_upload:
49 api.flavor.create_clean_device_dir(
50 api.flavor.device_dirs.perf_data_dir)
51
52
53 args = json.loads(api.properties['nanobench_flags'])
54 props = json.loads(api.properties['nanobench_properties'])
55 swarming_bot_id = api.vars.swarming_bot_id
56 swarming_task_id = api.vars.swarming_task_id
57 if do_upload:
58 args.append('--properties')
59
60
61 for k in sorted(props.keys()):
62 v = props[k]
63 if v == '${SWARMING_BOT_ID}':
64 v = swarming_bot_id
65 elif v == '${SWARMING_TASK_ID}':
66 v = swarming_task_id
67 if v != '':
68 args.extend([k, v])
69
70
71 if resources:
72 args.extend(['-i', api.flavor.device_dirs.resource_dir])
73 if skps:
74 args.extend(['--skps', api.flavor.device_dirs.skp_dir]),
75 if images:
76 args.extend(['--images', api.flavor.device_path_join(
77 api.flavor.device_dirs.images_dir, 'nanobench')])
78 if texttraces:
79 assert api.flavor.device_dirs.texttraces_dir
80 args.extend(['--texttraces', api.flavor.device_dirs.texttraces_dir])
81 if svgs:
82 args.extend(['--svgs', api.flavor.device_dirs.svg_dir])
83 if do_upload:
84 now = api.time.utcnow()
85 ts =
int(calendar.timegm(now.utctimetuple()))
86 json_path = api.flavor.device_path_join(
87 api.flavor.device_dirs.perf_data_dir,
88 'nanobench_%s_%d.json' % (api.properties['revision'], ts))
89 args.extend(['--outResultsFile', json_path])
90
91 api.run(api.flavor.step, 'nanobench', cmd=args,
92 abort_on_failure=False)
93
94
95 if do_upload:
96 api.file.ensure_directory(
97 'makedirs perf_dir',
98 api.flavor.host_dirs.perf_data_dir)
99 api.flavor.copy_directory_contents_to_host(
100 api.flavor.device_dirs.perf_data_dir,
101 api.flavor.host_dirs.perf_data_dir)
102
103