OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 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 """Tool for finding the cause of binary size bloat. | 6 """Tool for finding the cause of binary size bloat. |
7 | 7 |
8 See //tools/binary_size/README.md for example usage. | 8 See //tools/binary_size/README.md for example usage. |
9 | 9 |
10 Note: this tool will perform gclient sync/git checkout on your local repo if | 10 Note: this tool will perform gclient sync/git checkout on your local repo if |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 if metadata.Exists(): | 366 if metadata.Exists(): |
367 logging.info( | 367 logging.info( |
368 'Skipping diff for %s and %s. Matching diff already exists: %s', | 368 'Skipping diff for %s and %s. Matching diff already exists: %s', |
369 before.rev, after.rev, diff_path) | 369 before.rev, after.rev, diff_path) |
370 else: | 370 else: |
371 if os.path.exists(diff_path): | 371 if os.path.exists(diff_path): |
372 os.remove(diff_path) | 372 os.remove(diff_path) |
373 with open(diff_path, 'a') as diff_file: | 373 with open(diff_path, 'a') as diff_file: |
374 for d in self.diffs: | 374 for d in self.diffs: |
375 d.RunDiff(diff_file, before.dir, after.dir) | 375 d.RunDiff(diff_file, before.dir, after.dir) |
376 logging.info('See detailed diff results here: %s.', diff_path) | 376 logging.info('See detailed diff results here: %s', diff_path) |
377 metadata.Write() | 377 metadata.Write() |
378 self._AddDiffSummaryStat(before, after) | 378 self._AddDiffSummaryStat(before, after) |
379 | 379 |
380 def Summarize(self): | 380 def Summarize(self): |
381 if self._summary_stats: | 381 if self._summary_stats: |
382 path = os.path.join(self.archive_dir, 'last_diff_summary.txt') | 382 path = os.path.join(self.archive_dir, 'last_diff_summary.txt') |
383 with open(path, 'w') as f: | 383 with open(path, 'w') as f: |
384 stats = sorted( | 384 stats = sorted( |
385 self._summary_stats, key=lambda x: x[0].value, reverse=True) | 385 self._summary_stats, key=lambda x: x[0].value, reverse=True) |
386 _PrintAndWriteToFile(f, '\nDiff Summary') | 386 _PrintAndWriteToFile(f, '\nDiff Summary') |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 804 |
805 if i != 0: | 805 if i != 0: |
806 diff_mngr.MaybeDiff(i - 1, i) | 806 diff_mngr.MaybeDiff(i - 1, i) |
807 | 807 |
808 diff_mngr.Summarize() | 808 diff_mngr.Summarize() |
809 | 809 |
810 | 810 |
811 if __name__ == '__main__': | 811 if __name__ == '__main__': |
812 sys.exit(main()) | 812 sys.exit(main()) |
813 | 813 |
OLD | NEW |