File: plot_memory.py

package info (click to toggle)
python-memory-profiler 0.41%2Bgit20161018-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 280 kB
  • ctags: 163
  • sloc: python: 1,469; makefile: 24
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()