记时

问题描述 投票:4回答:1

我可以... %memit%timeit 同时运行一个IPython单元?那么在下面的情况下,它会运行多少次?

%memit -r 3
%timeit -r 2
my_awesome_function()
python profiling ipython
1个回答
0
投票

在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
© www.soinside.com 2019 - 2024. All rights reserved.