File: plot_memory.py

package info (click to toggle)
python-memory-profiler 0.61-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 540 kB
  • sloc: python: 2,220; makefile: 33
file content (18 lines) | stat: -rw-r--r-- 391 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""
Plot memory usage of a numeric computation using numpy and scipy
"""
import pylab as pl
import numpy as np
from memory_profiler import memory_usage
from scipy import linalg

X = np.random.randn(1000, 1000)

mem = memory_usage((linalg.qr, (X,)))
x = np.linspace(0, len(mem) * .1, len(mem))

p = pl.fill_between(x, mem)

pl.xlabel('time')
pl.ylabel('Memory consumption (in MB)')
pl.show()