Sampling line-by-line Python profiler.
pip install https://github.com/yuriiz/spyprofImport spyprof module at startup:
import spyprofProfiling reports will be written to spyprof directory periodically every 10 seconds and at application exit.
Profiling report measured with ITIMER_REAL timer will be written to spyprof/real.html.
Profiling report measured with ITIMER_PROF timer will be written to spyprof/prof.html.
Running following code:
import math
from time import sleep
import spyprof
def foo():
"""
CPU time consuming code.
"""
for i in range(10**8):
math.sqrt(i)
math.sqrt(i)
pass
def bar():
"""
Real time consuming code.
"""
sleep(10)
if __name__ == "__main__":
foo()
bar()Will result in the following reports:
| real.html | prof.html |
|---|---|
![]() |
![]() |

