Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: tools/deep_memory_profiler/lib/dump.py

Issue 754203004: There is a cyclic import in dmprof Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/deep_memory_profiler/lib/deep_dump.py ('k') | tools/deep_memory_profiler/lib/dumplist.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 5 import logging
6 import os
7
8 6
9 LOGGER = logging.getLogger('dmprof') 7 LOGGER = logging.getLogger('dmprof')
10 8
11 9
12 class Dump(object): 10 class Dump(object):
13 """Represents a heap profile dump.""" 11 """Represents a heap profile dump."""
14 def __init__(self): 12 def __init__(self):
15 pass 13 pass
16 14
17 @property 15 @property
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 Args: 62 Args:
65 path: A file path string to load. 63 path: A file path string to load.
66 log_header: A preceding string for log messages. 64 log_header: A preceding string for log messages.
67 65
68 Returns: 66 Returns:
69 A loaded Dump object. 67 A loaded Dump object.
70 68
71 Raises: 69 Raises:
72 ParsingException for invalid heap profile dumps. 70 ParsingException for invalid heap profile dumps.
73 """ 71 """
74 from lib.deep_dump import DeepDump 72 raise NotImplementedError
75 dump = DeepDump(path, os.stat(path).st_mtime)
76 with open(path, 'r') as f:
77 dump.load_file(f, log_header)
78 return dump
79
80
81 class DumpList(object):
82 """Represents a sequence of heap profile dumps.
83
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.
88 """
89
90 def __init__(self, dump_path_list):
91 self._dump_path_list = dump_path_list
92
93 @staticmethod
94 def load(path_list):
95 return DumpList(path_list)
96
97 def __len__(self):
98 return len(self._dump_path_list)
99
100 def __iter__(self):
101 for dump in self._dump_path_list:
102 yield Dump.load(dump)
103
104 def __getitem__(self, index):
105 return Dump.load(self._dump_path_list[index])
OLDNEW
« no previous file with comments | « tools/deep_memory_profiler/lib/deep_dump.py ('k') | tools/deep_memory_profiler/lib/dumplist.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698