OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """The deep heap profiler script for Chrome.""" | 5 """The deep heap profiler script for Chrome.""" |
6 | 6 |
7 import copy | 7 import copy |
8 import datetime | 8 import datetime |
9 import json | 9 import json |
10 import logging | 10 import logging |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 def load(self, prefix): | 701 def load(self, prefix): |
702 """Loads all related bucket files. | 702 """Loads all related bucket files. |
703 | 703 |
704 Args: | 704 Args: |
705 prefix: A prefix string for bucket file names. | 705 prefix: A prefix string for bucket file names. |
706 """ | 706 """ |
707 LOGGER.info('Loading bucket files.') | 707 LOGGER.info('Loading bucket files.') |
708 | 708 |
709 n = 0 | 709 n = 0 |
| 710 skipped = 0 |
710 while True: | 711 while True: |
711 path = '%s.%04d.buckets' % (prefix, n) | 712 path = '%s.%04d.buckets' % (prefix, n) |
712 if not os.path.exists(path): | 713 if not os.path.exists(path) or not os.stat(path).st_size: |
713 if n > 10: | 714 if skipped > 10: |
714 break | 715 break |
715 n += 1 | 716 n += 1 |
| 717 skipped += 1 |
716 continue | 718 continue |
717 LOGGER.info(' %s' % path) | 719 LOGGER.info(' %s' % path) |
718 with open(path, 'r') as f: | 720 with open(path, 'r') as f: |
719 self._load_file(f) | 721 self._load_file(f) |
720 n += 1 | 722 n += 1 |
| 723 skipped = 0 |
721 | 724 |
722 def _load_file(self, bucket_f): | 725 def _load_file(self, bucket_f): |
723 for line in bucket_f: | 726 for line in bucket_f: |
724 words = line.split() | 727 words = line.split() |
725 typeinfo = None | 728 typeinfo = None |
726 typeinfo_name = '' | 729 typeinfo_name = '' |
727 stacktrace_begin = 2 | 730 stacktrace_begin = 2 |
728 for index, word in enumerate(words): | 731 for index, word in enumerate(words): |
729 if index < 2: | 732 if index < 2: |
730 continue | 733 continue |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 else: | 1138 else: |
1136 return {} | 1139 return {} |
1137 | 1140 |
1138 @staticmethod | 1141 @staticmethod |
1139 def _find_all_dumps(dump_path): | 1142 def _find_all_dumps(dump_path): |
1140 prefix = Command._find_prefix(dump_path) | 1143 prefix = Command._find_prefix(dump_path) |
1141 dump_path_list = [dump_path] | 1144 dump_path_list = [dump_path] |
1142 | 1145 |
1143 n = int(dump_path[len(dump_path) - 9 : len(dump_path) - 5]) | 1146 n = int(dump_path[len(dump_path) - 9 : len(dump_path) - 5]) |
1144 n += 1 | 1147 n += 1 |
| 1148 skipped = 0 |
1145 while True: | 1149 while True: |
1146 p = '%s.%04d.heap' % (prefix, n) | 1150 p = '%s.%04d.heap' % (prefix, n) |
1147 if os.path.exists(p): | 1151 if os.path.exists(p) and os.stat(p).st_size: |
1148 dump_path_list.append(p) | 1152 dump_path_list.append(p) |
1149 else: | 1153 else: |
1150 break | 1154 if skipped > 10: |
| 1155 break |
| 1156 skipped += 1 |
1151 n += 1 | 1157 n += 1 |
1152 | 1158 |
1153 return dump_path_list | 1159 return dump_path_list |
1154 | 1160 |
1155 @staticmethod | 1161 @staticmethod |
1156 def _find_all_buckets(dump_path): | 1162 def _find_all_buckets(dump_path): |
1157 prefix = Command._find_prefix(dump_path) | 1163 prefix = Command._find_prefix(dump_path) |
1158 bucket_path_list = [] | 1164 bucket_path_list = [] |
1159 | 1165 |
1160 n = 0 | 1166 n = 0 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 errorcode = COMMANDS[action]().do(sys.argv) | 1820 errorcode = COMMANDS[action]().do(sys.argv) |
1815 except ParsingException, e: | 1821 except ParsingException, e: |
1816 errorcode = 1 | 1822 errorcode = 1 |
1817 sys.stderr.write('Exit by parsing error: %s\n' % e) | 1823 sys.stderr.write('Exit by parsing error: %s\n' % e) |
1818 | 1824 |
1819 return errorcode | 1825 return errorcode |
1820 | 1826 |
1821 | 1827 |
1822 if __name__ == '__main__': | 1828 if __name__ == '__main__': |
1823 sys.exit(main()) | 1829 sys.exit(main()) |
OLD | NEW |