Skip to content

Commit 2924fd2

Browse files
author
Armand Foucault
committed
Injecting local memory_profiler.py for dev
1 parent 11d7676 commit 2924fd2

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

mprof.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from collections import defaultdict
1212
from argparse import ArgumentParser, ArgumentError, REMAINDER, RawTextHelpFormatter
1313

14-
import memory_profiler as mp
14+
import importlib
15+
mp = importlib.import_module("memory_profiler", __file__)
16+
# import memory_profiler as mp
1517

1618
ALL_ACTIONS = ("run", "rm", "clean", "list", "plot")
1719
help_msg = """
@@ -202,7 +204,7 @@ def run_action():
202204
'Option 4: (--python flag present) "<PYTHON_MODULE> <ARG1> <ARG2>..." - profile python module\n'
203205
)
204206
args = parser.parse_args()
205-
207+
206208
if len(args.program) == 0:
207209
print("A program to run must be provided. Use -h for help")
208210
sys.exit(1)
@@ -329,8 +331,12 @@ def read_mprofile_file(filename):
329331
values = value.split(' ')
330332
f_name, mem_start, start, mem_end, end = values[:5]
331333
ts = func_ts.get(f_name, [])
332-
ts.append([float(start), float(end),
333-
float(mem_start), float(mem_end)])
334+
to_append = [float(start), float(end), float(mem_start), float(mem_end)]
335+
if len(values) >= 6:
336+
# There is a stack level field
337+
stack_level = values[5]
338+
to_append.append(int(stack_level))
339+
ts.append(to_append)
334340
func_ts[f_name] = ts
335341

336342
elif field == "CHLD":

0 commit comments

Comments
 (0)