mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
- add a dump_stats() method similar to that of the profile.Profile class
- don't use "file" as the name of local variables
This commit is contained in:
parent
c868d16e11
commit
9c43910a27
1 changed files with 10 additions and 2 deletions
|
|
@ -158,6 +158,14 @@ def add(self, *arg_list):
|
|||
self.stats[func] = add_func_stats(old_func_stat, stat)
|
||||
return self
|
||||
|
||||
def dump_stats(self, filename):
|
||||
"""Write the profile data to a file we know how to load back."""
|
||||
f = file(filename, 'wb')
|
||||
try:
|
||||
marshal.dump(self.stats, f)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
# list the tuple indices and directions for sorting,
|
||||
# along with some printable description
|
||||
sort_arg_dict_default = {
|
||||
|
|
@ -440,8 +448,8 @@ def compare (self, left, right):
|
|||
# func_name is a triple (file:string, line:int, name:string)
|
||||
|
||||
def func_strip_path(func_name):
|
||||
file, line, name = func_name
|
||||
return os.path.basename(file), line, name
|
||||
filename, line, name = func_name
|
||||
return os.path.basename(filename), line, name
|
||||
|
||||
def func_get_function_name(func):
|
||||
return func[2]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue