Index: tools/deep_memory_profiler/lib/dumplist.py |
diff --git a/tools/deep_memory_profiler/lib/dumplist.py b/tools/deep_memory_profiler/lib/dumplist.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..47df91ef07b0244488be9366170db2b799c1fccd |
--- /dev/null |
+++ b/tools/deep_memory_profiler/lib/dumplist.py |
@@ -0,0 +1,35 @@ |
+# Copyright 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import logging |
+ |
+from lib.deep_dump import DeepDump |
+ |
+LOGGER = logging.getLogger('dmprof') |
+ |
+class DumpList(object): |
+ """Represents a sequence of heap profile dumps. |
+ |
+ Individual dumps are loaded into memory lazily as the sequence is accessed, |
+ either while being iterated through or randomly accessed. Loaded dumps are |
+ not cached, meaning a newly loaded Dump object is returned every time an |
+ element in the list is accessed. |
+ """ |
+ |
+ def __init__(self, dump_path_list): |
+ self._dump_path_list = dump_path_list |
+ |
+ @staticmethod |
+ def load(path_list): |
+ return DumpList(path_list) |
+ |
+ def __len__(self): |
+ return len(self._dump_path_list) |
+ |
+ def __iter__(self): |
+ for dump in self._dump_path_list: |
+ yield DeepDump.load(dump) |
+ |
+ def __getitem__(self, index): |
+ return DeepDump.load(self._dump_path_list[index]) |