option for CPU time
belm0 opened this issue · 0 comments
Pyinstrument records duration using ‘wall-clock’ time. When you’re writing a program that downloads data, reads files, and talks to databases, all that time is included in the tracked time by pyinstrument.
That’s really important when debugging performance problems, since Python is often used as a ‘glue’ language between other services.
In the other 50% of python programs out there, CPU efficiency is important. Sure, for a synchronous Python program, CPU and wall time are basically the same, and pyinstrument can be used to find the places consuming CPU.
However, for async programs, since pyinstrument only offers wall time, it cannot be used to find what code is consuming CPU. For this use case, attributing time to sleep() or network blocking is unwanted.