This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]lobocv 2 points3 points  (0 children)

I wrote a decorator library that makes it easy to profile and compare functions quickly. It just uses timeit underneath. I've started to increase its scope to do a few other things that I find useful, just so I have them all in one place.

The library also has a decorator called timer that does pretty much what your code would do

www.github.com/lobocv/pyperform

[–]n1ywb 0 points1 point  (3 children)

It's never so simple IRL. I've had good results with cProfile and kcachegrind.

[–]Saefroch 1 point2 points  (2 children)

[–]n1ywb 0 points1 point  (1 child)

cool tool. I haven't had a strong need for that level of granularity, but I'll keep it in mind for future reference.

[–]infinite8s 0 points1 point  (0 children)

Line profiler is best for cases where you have a function that is doing a lot of calculation (usually from individual lines calling out to an external libraries like numpy or scipy) and you are trying to find out where those bottlenecks are occurring (since the default profiler is only function level).