파이썬 스크립트를 실행시키는 동안 일어난 시간 지연을 함수별로 간편하게 볼수 있네요




$ python3 -m cProfile -s cumulative test.py 2365911 function calls in 4.033 seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 4.033 4.033 {built-in method builtins.exec} 1 0.007 0.007 4.033 4.033 test.py:1() 1 0.212 0.212 4.026 4.026 test.py:6(calculate_outer) 1 2.816 2.816 3.775 3.775 test.py:33(calculate_inner) 2185304 0.959 0.000 0.959 0.000 {built-in method builtins.abs} 180600 0.039 0.000 0.039 0.000 {method 'append' of 'list' objects} 2 0.000 0.000 0.000 0.000 {built-in method builtins.len} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}




이것저것 병목 원인 찾는 툴들 공부해보고 있는데 품 안들이고 큰 그림 보는데는 이게 최고인 것 같습니다. 빌트인 기능이라 특별히 설치할 것도 없고요.