(2順目)
レシピ4.3
line_profilerのWindows版が入手できないのであきらめ
レシピ4.4
memory_profilerはAnacondaのsite-packagesにinstall済みでした。
実行してみると
Line # Mem usage Increment Line Contents
================================================
7 48.1 MiB 0.0 MiB def simulate(iterations, n=10000):
8 50.6 MiB 2.5 MiB s = step(iterations, n)
9 52.5 MiB 1.9 MiB x = np.cumsum(s, axis=0)
10 52.5 MiB 0.0 MiB bins = np.arange(-30, 30, 1)
11 52.7 MiB 0.1 MiB y = np.vstack([np.histogram(x[i,:], bins)[0] for i in range(iterations)])
12 52.7 MiB 0.0 MiB return y
結構メモリ使っている
レシピ4.5
3項に
b = a.reshape((1,-1) )
とあるが-1は列数を推測設定してくれるという意味になる
a配列は10×10配列なのでb配列は
(1,10000)の配列となる(reshapeはセル数が一致する必要がある)