From 6c77514f5b0aa0339563e5143d228432b6fb75bb Mon Sep 17 00:00:00 2001 From: fanzuquan Date: Wed, 19 Oct 2022 09:43:35 +0800 Subject: [PATCH] fit plotting data to xlim --- mprof.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mprof.py b/mprof.py index 7753d7e..2a88744 100644 --- a/mprof.py +++ b/mprof.py @@ -430,14 +430,18 @@ def plot_file(filename, index=0, timestamps=True, children=True, options=None): mem = np.asarray(mem) t = np.asarray(t) + global_start = t[0] + t = t - global_start + + if options.xlim is not None: + cond = (t >= options.xlim[0]) & (t <= options.xlim[1]) + mem, t = mem[cond], t[cond] + ind = t.argsort() mem = mem[ind] t = t[ind] # Plot curves - global_start = float(t[0]) - t = t - global_start - max_mem = mem.max() max_mem_ind = mem.argmax()