Skip to content

Commit e9d5356

Browse files
committed
Trend lines switch '-s' now plots the actual trend line
1 parent 7d87e10 commit e9d5356

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

mprof.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,17 @@ def plot_file(filename, index=0, timestamps=True, children=True, options=None):
412412
mem_trend = None
413413
if show_trend_slope:
414414
# Compute trend line
415-
mem_slope = np.polyfit(t, mem, 1)
416-
mem_trend = np.poly1d(mem_slope)
415+
mem_trend = np.polyfit(t, mem, 1)
416+
417417
# Append slope to label
418-
mem_line_label = mem_line_label + " slope {0:.5f}".format(mem_slope[0])
418+
mem_line_label = mem_line_label + " slope {0:.5f}".format(mem_trend[0])
419419

420420
pl.plot(t, mem, "+-" + mem_line_colors[index % len(mem_line_colors)],
421421
label=mem_line_label)
422422

423423
if show_trend_slope:
424424
# Plot the trend line
425-
pl.plot(t, mem_trend(mem), "--", linewidth=0.5, color="#00e3d8")
425+
pl.plot(t, t*mem_trend[0] + mem_trend[1], "--", linewidth=0.5, color="#00e3d8")
426426

427427
bottom, top = pl.ylim()
428428
bottom += 0.001
@@ -441,17 +441,17 @@ def plot_file(filename, index=0, timestamps=True, children=True, options=None):
441441
child_mem_trend_label = ""
442442
if show_trend_slope:
443443
# Compute trend line
444-
child_mem_slope = np.polyfit(cts, cmem, 1)
445-
cmem_trend = np.poly1d(child_mem_slope)
446-
child_mem_trend_label = " slope {0:.5f}".format(child_mem_slope[0])
444+
cmem_trend = np.polyfit(cts, cmem, 1)
445+
446+
child_mem_trend_label = " slope {0:.5f}".format(cmem_trend[0])
447447

448448
# Plot the line to the figure
449449
pl.plot(cts, cmem, "+-" + mem_line_colors[(idx + 1) % len(mem_line_colors)],
450450
label="child {}{}".format(proc, child_mem_trend_label))
451451

452452
if show_trend_slope:
453453
# Plot the trend line
454-
pl.plot(cts, cmem_trend(cts), "--", linewidth=0.5, color="black")
454+
pl.plot(cts, cts*cmem_trend[0] + cmem_trend[1], "--", linewidth=0.5, color="black")
455455

456456
# Detect the maximal child memory point
457457
cmax_mem = cmem.max()
@@ -839,4 +839,4 @@ def main():
839839
actions[get_action()]()
840840

841841
if __name__ == "__main__":
842-
main()
842+
main()

0 commit comments

Comments
 (0)