top | item 24837485

(no title)

abuckenheimer | 5 years ago

Very cool, py-spy[1] has been an invaluable tool in my development process since jvns blogged[2] about it. The power of being able to visualize where your code is spending its time is so obvious and I'm glad people are building tools to make that easier.

As a quick compare and contrast between py-spy and pyinstrument it looks like py-spy has the advantage of being able to attach to an already running process which is super useful when your program is stuck and you don't know why. I haven't used pyinstrument yet but I do like the fact that it can do its flame graph in the console, sometimes I find saving down an svg file and opening up the browser a bit arduous. Excited to give it a try.

[1] https://github.com/benfred/py-spy

[2] https://jvns.ca/blog/2018/09/08/an-awesome-new-python-profil...

discuss

order

synparb|5 years ago

Another relatively new addition to the python statistical sampler space is Austin[1], that has a lot of similar features to py-spy. I haven't made a direct comparison yet between the two.

[1] https://github.com/P403n1x87/austin

formerly_proven|5 years ago

I see a lot of tracing and sampling profilers for Python, but are there any profilers for manual instrumentation (goes by a bunch of names, frame profiling, performance telemetry, APM etc.)?

galacticdessert|5 years ago

py-spy seems also very interesting, thanks for linking it. I always found cPython to be quite difficult to work with, and usually reverted to line_profiler or some sort of UI for cprof files. The main added benefits of pyInstrument to me is the high signal vs noise ratio, as it is evidently clear what is taking the most time while retaining the option to dive deeper.

I am also curious to try out the on-demand profiling integration with Flask, seems like a cool thing to have running in the background for my side projects

baq|5 years ago

py-spy is absolutely invaluable for the attach-to-process feature. also, nothing beats the adrenaline rush of attaching to a prod process and leaving it in a paused state after collecting a profile (true story! SIGCONT is your friend).