10PYTHON_VERSION_COMPATIBILITY =
"PY3"
15 'recipe_engine/context',
18 'recipe_engine/properties',
19 'recipe_engine/raw_io',
26MAGIC_SEPERATOR =
'#$%^&*'
27TOTAL_SIZE_BYTES_KEY =
"total_size_bytes"
31 result.presentation.properties[
'binary_size_%s' % source] = binary_size
37 checkout_root = api.checkout.default_checkout_root
38 api.checkout.bot_update(checkout_root=checkout_root)
40 out_dir = api.vars.swarming_out_dir
42 bin_dir = api.vars.build_dir
44 api.file.ensure_directory(
'mkdirs out_dir', out_dir, mode=0o777)
47 with api.context(cwd=bin_dir):
48 files = api.file.glob_paths(
52 test_data=[
'pathkit.wasm'])
53 analyzed +=
len(files)
57 files = api.file.glob_paths(
61 test_data=[
'pathkit.js'])
62 analyzed +=
len(files)
66 files = api.file.glob_paths(
70 test_data=[
'pathkit.js.mem'])
71 analyzed +=
len(files)
75 files = api.file.glob_paths(
76 'find flutter library',
79 test_data=[
'libflutter.so'])
80 analyzed +=
len(files)
84 files = api.file.glob_paths(
88 test_data=[
'libskia.so'])
89 analyzed +=
len(files)
93 files = api.file.glob_paths(
97 test_data=[
'skottie_tool'])
98 analyzed +=
len(files)
102 files = api.file.glob_paths(
107 analyzed +=
len(files)
112 raise Exception(
'No files were analyzed!')
117 for k
in sorted(api.vars.builder_cfg.keys()):
118 if not k
in [
'role']:
119 keys.extend([k, api.vars.builder_cfg[k]])
120 keystr =
' '.
join(keys)
123 'gitHash', api.properties[
'revision'],
124 'swarming_bot_id', api.vars.swarming_bot_id,
125 'swarming_task_id', api.vars.swarming_task_id,
128 if api.vars.is_trybot:
130 'issue', api.vars.issue,
131 'patchset', api.vars.patchset,
132 'patch_storage', api.vars.patch_storage,
134 propstr =
' '.
join(str(prop)
for prop
in props)
135 return (keystr, propstr)
143 skia_dir = checkout_root.join(
'skia')
144 with api.context(cwd=skia_dir):
145 script = skia_dir.join(
'infra',
'bots',
'buildstats',
147 step_data = api.run(api.step,
'Analyze %s' % f,
148 cmd=[
'python3', script, f, out_dir, keystr, propstr,
149 TOTAL_SIZE_BYTES_KEY, MAGIC_SEPERATOR],
150 stdout=api.raw_io.output())
151 if step_data
and step_data.stdout:
152 sections = step_data.stdout.decode(
'utf-8').split(MAGIC_SEPERATOR)
153 result = api.step.active_result
154 logs = result.presentation.logs
155 logs[
'perf_json'] = sections[1].split(
'\n')
158 ast.literal_eval(sections[1])
160 .
get(api.path.basename(f), {})
162 .
get(TOTAL_SIZE_BYTES_KEY, {})))
168 bloaty_exe = api.path.start_dir.join(
'bloaty',
'bloaty')
171 skia_dir = checkout_root.join(
'skia')
172 with api.context(cwd=skia_dir):
173 script = skia_dir.join(
'infra',
'bots',
'buildstats',
175 step_data = api.run(api.step,
'Analyze %s' % f,
176 cmd=[
'python3', script, f, out_dir, keystr, propstr, bloaty_exe,
177 TOTAL_SIZE_BYTES_KEY, MAGIC_SEPERATOR],
178 stdout=api.raw_io.output())
179 if step_data
and step_data.stdout:
180 sections = step_data.stdout.decode(
'utf-8').split(MAGIC_SEPERATOR)
181 result = api.step.active_result
182 logs = result.presentation.logs
183 logs[
'perf_json'] = sections[2].split(
'\n')
186 ast.literal_eval(sections[2])
188 .
get(api.path.basename(f), {})
190 .
get(TOTAL_SIZE_BYTES_KEY, {})))
196 bloaty_exe = api.path.start_dir.join(
'bloaty',
'bloaty')
200 skia_dir = checkout_root.join(
'skia')
201 with api.context(cwd=skia_dir):
202 stripped = api.vars.build_dir.join(
'libflutter_stripped.so')
203 script = skia_dir.join(
'infra',
'bots',
'buildstats',
204 'buildstats_flutter.py')
205 config =
"skia_in_flutter"
206 lib_name =
"libflutter.so"
207 step_data = api.run(api.step,
'Analyze flutter',
208 cmd=[
'python3', script, stripped, out_dir, keystr, propstr,
209 bloaty_exe, f, config, TOTAL_SIZE_BYTES_KEY, lib_name,
211 stdout=api.raw_io.output())
212 if step_data
and step_data.stdout:
213 sections = step_data.stdout.decode(
'utf-8').split(MAGIC_SEPERATOR)
214 result = api.step.active_result
215 logs = result.presentation.logs
218 logs[
'bloaty_file_symbol_short'] = sections[1].split(
'\n')
219 logs[
'bloaty_file_symbol_full'] = sections[2].split(
'\n')
220 logs[
'bloaty_symbol_file_short'] = sections[3].split(
'\n')
221 logs[
'bloaty_symbol_file_full'] = sections[4].split(
'\n')
222 logs[
'perf_json'] = sections[5].split(
'\n')
225 ast.literal_eval(sections[5])
229 .
get(TOTAL_SIZE_BYTES_KEY, {})))
235 bloaty_exe = api.path.start_dir.join(
'bloaty',
'bloaty')
239 skia_dir = checkout_root.join(
'skia')
240 with api.context(cwd=skia_dir):
241 script = skia_dir.join(
'infra',
'bots',
'buildstats',
242 'buildstats_wasm.py')
243 step_data = api.run(api.step,
'Analyze wasm',
244 cmd=[
'python3', script, f, out_dir, keystr, propstr, bloaty_exe,
245 TOTAL_SIZE_BYTES_KEY, MAGIC_SEPERATOR],
246 stdout=api.raw_io.output())
247 if step_data
and step_data.stdout:
248 sections = step_data.stdout.decode(
'utf-8').split(MAGIC_SEPERATOR)
249 result = api.step.active_result
250 logs = result.presentation.logs
253 logs[
'bloaty_symbol_short'] = sections[1].split(
'\n')
254 logs[
'bloaty_symbol_full'] = sections[2].split(
'\n')
255 logs[
'perf_json'] = sections[3].split(
'\n')
257 ast.literal_eval(str(sections[3]))
259 .
get(api.path.basename(f), {})
261 .
get(TOTAL_SIZE_BYTES_KEY, {})))
267 env = {
'DOCKER_CONFIG':
'/home/chrome-bot/.docker'}
269 skia_dir = checkout_root.join(
'skia')
270 with api.context(cwd=skia_dir):
271 script = skia_dir.join(
'infra',
'bots',
'buildstats',
273 api.run(api.step,
'Make code size treemap %s' % f,
274 cmd=[
'python3', script, f, out_dir],
275 stdout=api.raw_io.output())
279 builder =
'BuildStats-Debian10-EMCC-wasm-Release-PathKit'
281 api.test(
'normal_bot') +
282 api.properties(buildername=builder,
283 repository=
'https://skia.googlesource.com/skia.git',
285 swarm_out_dir=
'[SWARM_OUT_DIR]',
286 path_config=
'kitchen') +
287 api.step_data(
'get swarming bot id',
288 stdout=api.raw_io.output(
'skia-bot-123')) +
289 api.step_data(
'get swarming task id',
290 stdout=api.raw_io.output(
'123456abc')) +
291 api.step_data(
'Analyze [START_DIR]/build/pathkit.js.mem',
292 stdout=api.raw_io.output(sample_web)) +
293 api.step_data(
'Analyze [START_DIR]/build/libskia.so',
294 stdout=api.raw_io.output(sample_cpp)) +
295 api.step_data(
'Analyze wasm',
296 stdout=api.raw_io.output(sample_wasm)) +
297 api.step_data(
'Analyze flutter',
298 stdout=api.raw_io.output(sample_flutter))
303 api.properties(buildername=builder,
304 repository=
'https://skia.googlesource.com/skia.git',
306 swarm_out_dir=
'[SWARM_OUT_DIR]',
307 patch_repo=
'https://skia.googlesource.com/skia.git',
308 path_config=
'kitchen') +
309 api.step_data(
'get swarming bot id',
310 stdout=api.raw_io.output(
'skia-bot-123')) +
311 api.step_data(
'get swarming task id',
312 stdout=api.raw_io.output(
'123456abc')) +
313 api.properties(patch_storage=
'gerrit') +
314 api.properties.tryserver(
316 gerrit_project=
'skia',
317 gerrit_url=
'https://skia-review.googlesource.com/',
319 api.step_data(
'Analyze [START_DIR]/build/pathkit.js.mem',
320 stdout=api.raw_io.output(sample_web)) +
321 api.step_data(
'Analyze [START_DIR]/build/libskia.so',
322 stdout=api.raw_io.output(sample_cpp)) +
323 api.step_data(
'Analyze wasm',
324 stdout=api.raw_io.output(sample_wasm)) +
325 api.step_data(
'Analyze flutter',
326 stdout=api.raw_io.output(sample_flutter))
338 "total_size_bytes": 7391117,
339 "gzip_size_bytes": 2884841
356 "total_size_bytes": 7391117,
357 "gzip_size_bytes": 2884841
377 "total_size_bytes": 7391117,
378 "gzip_size_bytes": 2884841
404 "total_size_bytes": 1256676
def analyze_flutter_lib(api, checkout_root, out_dir, files)
def add_binary_size_output_property(result, source, binary_size)
def analyze_cpp_lib(api, checkout_root, out_dir, files)
def analyze_wasm_file(api, checkout_root, out_dir, files)
def analyze_web_file(api, checkout_root, out_dir, files)
def make_treemap(api, checkout_root, out_dir, files)
const myers::Point & get(const myers::Segment &)
static SkString join(const CommandLineFlags::StringArray &)