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…
PyInstrument – A statistical Python profile that focuses on the slow parts
11–20 of 23 posts
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#12Very 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…
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#13> The standard Python profilers profile and cProfile show you a big list of functions, ordered by the time spent in each function. This is great, but it can be difficult to interpret why those functions are getting called. It's more helpful to know why those functions are called, and which parts of user code were involved. Note that you can use something like gprof2dot to convert pstats dump from cProfile to a visual…
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#14I could guess from context, but thought it might be good to point out.
Source: From the repo: "Pyinstrument is a Python profiler"
(Feel free to delete this comment after fixing the typo, or not :) )
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#15This gives nicer summarization/presentation than Django Debug Toolbar's profiler, so seems like a good one to have in the toolbox.
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#16> The standard Python profilers profile and cProfile show you a big list of functions, ordered by the time spent in each function. This is great, but it can be difficult to interpret why those functions are getting called. It's more helpful to know why those functions are called, and which parts of user code were involved. Note that you can use something like gprof2dot to convert pstats dump from cProfile to a visual…
The biggest problem with the standard profiler is that the reported times are not split by code path. For example, if you have two parts of your code that call the same library function, and you want to know which path is the slow path...you can't. The time reported for each line is a sum of all times/paths it was called. Worse, the visualization tools don't hint that this is the case, so you end up with very incorrect plots. Pyinstrument will give you the time, by path. Super useful, and a huge time saver!
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#17> Shows you why your code is slow! Because you wrote it in Python. Seriously, Python is probably the slowest mainstream language of all. If you’re building something where performance matters, you should be using a different language.
And the python ecosystem understands this, with those performance critical bits being implemented in C/fortran/whatever, not pure python.
Re: PyInstrument – A statistical Python profile that focuses on the slow parts
#18Very 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…