0
IPython 노트북에는 셀 내용을 프로파일 링하는 방법이 있습니까?노트북 프로파일 링 - IPython
그렇지 않은 경우 셀 또는 전체 전자 필기장의 일부분을 프로파일 링하는 방법은 무엇입니까?
IPython 노트북에는 셀 내용을 프로파일 링하는 방법이 있습니까?노트북 프로파일 링 - IPython
그렇지 않은 경우 셀 또는 전체 전자 필기장의 일부분을 프로파일 링하는 방법은 무엇입니까?
IPython 노트북은 매우 편리한 %prun
및 %%prun
명령을 가지고 있습니다. %prun
은 코드 한 줄을 프로파일 링하는 데 사용되고 %%prun
은 전체 셀을 프로파일 링하는 데 사용됩니다.
: http://ipython.readthedocs.org/en/stable/interactive/magics.html#magic-prun
이 짧은 사용 예는 다음과 같습니다
%%prun -s cumulative
import numpy as np
import scipy.linalg as la
for i in range(30):
a = np.random.randint(100,size=(1000, 1000))
la.inv(a)
이 셀을 실행하는 경우를, 출력은
1053 function calls in 4.152 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.001 0.001 4.152 4.152 <string>:3(<module>)
30 3.502 0.117 3.505 0.117 basic.py:612(inv)
30 0.646 0.022 0.646 0.022 {method 'randint' of 'mtrand.RandomState' objects}
30 0.000 0.000 0.002 0.000 lapack.py:382(get_lapack_funcs)
내가 가장 좋아하는 프로파일 링 같은 것입니다 기술은 % timeit이지만 그림과 같이 훨씬 더 많은 가능성이 있습니다. [여기] (http://pynash.org/2013/03/06/timing-and-profiling.html) – Jakob