我可以... %memit
和 %timeit
同时运行一个IPython单元?那么在下面的情况下,它会运行多少次?
%memit -r 3
%timeit -r 2
my_awesome_function()
在Jupyter中尝试了一些组合,最后使用了 %%time
细胞水平和 %memit
在行级。
%%time
d = 64
nb = 1000000
nq = 10000
%memit xb = np.random.random((nb, d))
%memit xq = np.random.random((nq, d))
time.sleep(5)
其中产出:
peak memory: 1252.40 MiB, increment: 457.10 MiB
peak memory: 797.77 MiB, increment: 2.48 MiB
CPU times: user 866 ms, sys: 230 ms, total: 1.1 s
Wall time: 6.34 s