Python profiling pyinstrument Github pip install pyinstrument from pyinstrument import Profiler profiler = Profiler() profiler.start() # code you want to profile profiler.stop() profiler.print()