IPythonデータサイエンスクックブック

レシピ4.4

psutilはすでにanacondaに入っていたが、memory_profilerは入っていなかったようで

installした結果ver0.4が入った。

本のようにipythonからコードを入れて見たがうまくいかない

memory_profileのdocment : (https://pypi.python.org/pypi/memory_profiler) に書いてあるようにipythonではなく

command lineから実行してみるとちゃんと動作はしているのでinstallはちゃんと入っているようである。

 

D:\IPythonnotebook\cookbook>python -m memory_profiler simulation.py
Filename: simulation.py

Line # Mem usage Increment Line Contents
================================================
7 36.543 MiB 0.000 MiB @profile
8 def simulate(iterations, n=10000):
9 227.754 MiB 191.211 MiB s = step(iterations, n)
10 418.883 MiB 191.129 MiB x = np.cumsum(s, axis=0)
11 418.895 MiB 0.012 MiB bins = np.arange(-30, 30, 1)
12 424.496 MiB 5.602 MiB y = np.vstack([np.histogram(x[i,:], bins)
[0] for i in range(iterations)])
13 424.496 MiB 0.000 MiB return y