| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import copy | 5 import copy |
| 6 import datetime | 6 import datetime |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import time | 10 import time |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 """ | 400 """ |
| 401 words = stacktrace_line.split() | 401 words = stacktrace_line.split() |
| 402 if len(words) < BUCKET_ID + 1: | 402 if len(words) < BUCKET_ID + 1: |
| 403 return False | 403 return False |
| 404 if words[BUCKET_ID - 1] != '@': | 404 if words[BUCKET_ID - 1] != '@': |
| 405 return False | 405 return False |
| 406 return True | 406 return True |
| 407 | 407 |
| 408 | 408 |
| 409 class DumpList(object): | 409 class DumpList(object): |
| 410 """Represents a sequence of heap profile dumps.""" | 410 """Represents a sequence of heap profile dumps. |
| 411 | 411 |
| 412 def __init__(self, dump_list): | 412 Individual dumps are loaded into memory lazily as the sequence is accessed, |
| 413 self._dump_list = dump_list | 413 either while being iterated through or randomly accessed. Loaded dumps are |
| 414 not cached, meaning a newly loaded Dump object is returned every time an |
| 415 element in the list is accessed. |
| 416 """ |
| 417 |
| 418 def __init__(self, dump_path_list): |
| 419 self._dump_path_list = dump_path_list |
| 414 | 420 |
| 415 @staticmethod | 421 @staticmethod |
| 416 def load(path_list): | 422 def load(path_list): |
| 417 LOGGER.info('Loading heap dump profiles.') | 423 return DumpList(path_list) |
| 418 dump_list = [] | |
| 419 for path in path_list: | |
| 420 dump_list.append(Dump.load(path, ' ')) | |
| 421 return DumpList(dump_list) | |
| 422 | 424 |
| 423 def __len__(self): | 425 def __len__(self): |
| 424 return len(self._dump_list) | 426 return len(self._dump_path_list) |
| 425 | 427 |
| 426 def __iter__(self): | 428 def __iter__(self): |
| 427 for dump in self._dump_list: | 429 for dump in self._dump_path_list: |
| 428 yield dump | 430 yield Dump.load(dump) |
| 429 | 431 |
| 430 def __getitem__(self, index): | 432 def __getitem__(self, index): |
| 431 return self._dump_list[index] | 433 return Dump.load(self._dump_path_list[index]) |
| 432 | 434 |
| 433 | 435 |
| 434 class ProcMapsEntryAttribute(ExclusiveRangeDict.RangeAttribute): | 436 class ProcMapsEntryAttribute(ExclusiveRangeDict.RangeAttribute): |
| 435 """Represents an entry of /proc/maps in range_dict.ExclusiveRangeDict.""" | 437 """Represents an entry of /proc/maps in range_dict.ExclusiveRangeDict.""" |
| 436 _DUMMY_ENTRY = procfs.ProcMapsEntry( | 438 _DUMMY_ENTRY = procfs.ProcMapsEntry( |
| 437 0, # begin | 439 0, # begin |
| 438 0, # end | 440 0, # end |
| 439 '-', # readable | 441 '-', # readable |
| 440 '-', # writable | 442 '-', # writable |
| 441 '-', # executable | 443 '-', # executable |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 Returns: | 480 Returns: |
| 479 A pair of an integer indicating a line number after skipped, and a | 481 A pair of an integer indicating a line number after skipped, and a |
| 480 boolean value which is True if found a line which skipping_condition | 482 boolean value which is True if found a line which skipping_condition |
| 481 is False for. | 483 is False for. |
| 482 """ | 484 """ |
| 483 while skipping_condition(index): | 485 while skipping_condition(index): |
| 484 index += 1 | 486 index += 1 |
| 485 if index >= max_index: | 487 if index >= max_index: |
| 486 return index, False | 488 return index, False |
| 487 return index, True | 489 return index, True |
| OLD | NEW |