OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Generate a spatial analysis against an arbitrary library. | 6 """Generate a spatial analysis against an arbitrary library. |
7 | 7 |
8 Adapted for Skia's use case from | 8 Adapted for Skia's use case from |
9 chromium/src/tools/binary_size/run_binary_size_analysis.py. Main changes: | 9 chromium/src/tools/binary_size/run_binary_size_analysis.py. Main changes: |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 import sys | 88 import sys |
89 import tempfile | 89 import tempfile |
90 import time | 90 import time |
91 import urllib2 | 91 import urllib2 |
92 | 92 |
93 import binary_size_utils | 93 import binary_size_utils |
94 import elf_symbolizer | 94 import elf_symbolizer |
95 | 95 |
96 from recipe_engine.types import freeze | 96 from recipe_engine.types import freeze |
97 | 97 |
98 # Skia addition | |
99 from common.skia import global_constants | |
100 | |
101 # Node dictionary keys. These are output in json read by the webapp so | 98 # Node dictionary keys. These are output in json read by the webapp so |
102 # keep them short to save file size. | 99 # keep them short to save file size. |
103 # Note: If these change, the webapp must also change. | 100 # Note: If these change, the webapp must also change. |
104 NODE_TYPE_KEY = 'k' | 101 NODE_TYPE_KEY = 'k' |
105 NODE_NAME_KEY = 'n' | 102 NODE_NAME_KEY = 'n' |
106 NODE_CHILDREN_KEY = 'children' | 103 NODE_CHILDREN_KEY = 'children' |
107 NODE_SYMBOL_TYPE_KEY = 't' | 104 NODE_SYMBOL_TYPE_KEY = 't' |
108 NODE_SYMBOL_SIZE_KEY = 'value' | 105 NODE_SYMBOL_SIZE_KEY = 'value' |
109 NODE_MAX_DEPTH_KEY = 'maxDepth' | 106 NODE_MAX_DEPTH_KEY = 'maxDepth' |
110 NODE_LAST_PATH_ELEMENT_KEY = 'lastPathElement' | 107 NODE_LAST_PATH_ELEMENT_KEY = 'lastPathElement' |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 json_data = {'tree_data': tree_root, | 328 json_data = {'tree_data': tree_root, |
332 'githash': ha, | 329 'githash': ha, |
333 'commit_ts': ts, | 330 'commit_ts': ts, |
334 'key': {'source_type': 'binary_size'}, | 331 'key': {'source_type': 'binary_size'}, |
335 'total_size': sum(GetTreeSizes(tree_root).values()),} | 332 'total_size': sum(GetTreeSizes(tree_root).values()),} |
336 tmpfile = tempfile.NamedTemporaryFile(delete=False).name | 333 tmpfile = tempfile.NamedTemporaryFile(delete=False).name |
337 with open(tmpfile, 'w') as out: | 334 with open(tmpfile, 'w') as out: |
338 # Use separators without whitespace to get a smaller file. | 335 # Use separators without whitespace to get a smaller file. |
339 json.dump(json_data, out, separators=(',', ':')) | 336 json.dump(json_data, out, separators=(',', ':')) |
340 | 337 |
341 GS_PREFIX = 'gs://' + global_constants.GS_GM_BUCKET + '/' | 338 GS_PREFIX = 'gs://chromium-skia-gm/' |
342 # Writes to Google Storage for visualization. | 339 # Writes to Google Storage for visualization. |
343 subprocess.check_call(GetGsCopyCommandList( | 340 subprocess.check_call(GetGsCopyCommandList( |
344 gsutil, tmpfile, GS_PREFIX + 'size/' + ha + '.json')) | 341 gsutil, tmpfile, GS_PREFIX + 'size/' + ha + '.json')) |
345 # Updates the latest data. | 342 # Updates the latest data. |
346 if not issue: | 343 if not issue: |
347 subprocess.check_call(GetGsCopyCommandList(gsutil, tmpfile, | 344 subprocess.check_call(GetGsCopyCommandList(gsutil, tmpfile, |
348 GS_PREFIX + 'size/latest.json')) | 345 GS_PREFIX + 'size/latest.json')) |
349 # Writes an extra copy using year/month/day/hour path for easy ingestion. | 346 # Writes an extra copy using year/month/day/hour path for easy ingestion. |
350 with open(tmpfile, 'w') as out: | 347 with open(tmpfile, 'w') as out: |
351 json.dump(GetBenchDict(ha, tree_root), out, separators=(',', ':')) | 348 json.dump(GetBenchDict(ha, tree_root), out, separators=(',', ':')) |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 else: | 808 else: |
812 # Just a guess. Hopefully all paths in the input file are absolute. | 809 # Just a guess. Hopefully all paths in the input file are absolute. |
813 symbol_path_origin_dir = os.path.abspath(os.getcwd()) | 810 symbol_path_origin_dir = os.path.abspath(os.getcwd()) |
814 DumpCompactTree(symbols, symbol_path_origin_dir, opts.githash, | 811 DumpCompactTree(symbols, symbol_path_origin_dir, opts.githash, |
815 opts.commit_ts, opts.issue_number, opts.gsutil_path) | 812 opts.commit_ts, opts.issue_number, opts.gsutil_path) |
816 print 'Report data uploaded to GS.' | 813 print 'Report data uploaded to GS.' |
817 | 814 |
818 | 815 |
819 if __name__ == '__main__': | 816 if __name__ == '__main__': |
820 sys.exit(main()) | 817 sys.exit(main()) |
OLD | NEW |