OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import logging |
| 6 |
| 7 from lib.deep_dump import DeepDump |
| 8 |
| 9 LOGGER = logging.getLogger('dmprof') |
| 10 |
| 11 class DumpList(object): |
| 12 """Represents a sequence of heap profile dumps. |
| 13 |
| 14 Individual dumps are loaded into memory lazily as the sequence is accessed, |
| 15 either while being iterated through or randomly accessed. Loaded dumps are |
| 16 not cached, meaning a newly loaded Dump object is returned every time an |
| 17 element in the list is accessed. |
| 18 """ |
| 19 |
| 20 def __init__(self, dump_path_list): |
| 21 self._dump_path_list = dump_path_list |
| 22 |
| 23 @staticmethod |
| 24 def load(path_list): |
| 25 return DumpList(path_list) |
| 26 |
| 27 def __len__(self): |
| 28 return len(self._dump_path_list) |
| 29 |
| 30 def __iter__(self): |
| 31 for dump in self._dump_path_list: |
| 32 yield DeepDump.load(dump) |
| 33 |
| 34 def __getitem__(self, index): |
| 35 return DeepDump.load(self._dump_path_list[index]) |
OLD | NEW |