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.
9 LOGGER
= logging
.getLogger('dmprof')
13 """Represents a heap profile dump."""
19 raise NotImplementedError
23 raise NotImplementedError
27 raise NotImplementedError
31 raise NotImplementedError
34 def iter_stacktrace(self
):
35 raise NotImplementedError
37 def global_stat(self
, name
):
38 raise NotImplementedError
42 raise NotImplementedError
46 raise NotImplementedError
49 def pageframe_length(self
):
50 raise NotImplementedError
53 def pageframe_encoding(self
):
54 raise NotImplementedError
57 def has_pagecount(self
):
58 raise NotImplementedError
61 def load(path
, log_header
='Loading a heap profile dump: '):
62 """Loads a heap profile dump.
65 path: A file path string to load.
66 log_header: A preceding string for log messages.
72 ParsingException for invalid heap profile dumps.
74 from lib
.deep_dump
import DeepDump
75 dump
= DeepDump(path
, os
.stat(path
).st_mtime
)
76 with
open(path
, 'r') as f
:
77 dump
.load_file(f
, log_header
)
81 class DumpList(object):
82 """Represents a sequence of heap profile dumps.
84 Individual dumps are loaded into memory lazily as the sequence is accessed,
85 either while being iterated through or randomly accessed. Loaded dumps are
86 not cached, meaning a newly loaded Dump object is returned every time an
87 element in the list is accessed.
90 def __init__(self
, dump_path_list
):
91 self
._dump
_path
_list
= dump_path_list
95 return DumpList(path_list
)
98 return len(self
._dump
_path
_list
)
101 for dump
in self
._dump
_path
_list
:
102 yield Dump
.load(dump
)
104 def __getitem__(self
, index
):
105 return Dump
.load(self
._dump
_path
_list
[index
])