I’ve a HTTP server written in Python that accepts a large binary file (>50MB) and performs some file related computation (decryption, decompression …) on the file. I want to get a good estimate of the the amount of time it takes to execute these operations. My python server is running on a multi CPU and multi core server on Ubuntu 11.10.
Currently I’m just doing a time diff of (date.now() to get the execution times for various operations. I know there are couple of Python modules that provide profiling capabilities. However, my understanding is they are limited to small code snippets only.
What are my other options ?
Thanks.
I’d say that cProfile is pretty solid, and definitely an improvement on using something like date.now(). Here is what cProfile produces for a comparison of a useless and slightly less useless fibonacci generator.
Here is the code I used:
cProfile pretty clearly tells me how slow fib is running, and gives me nice data on time per call / number of calls, as well as how much total time was spent in the method. Obviously this is trivial/toy code, but I regularly use cProfile to get a feel for where my code is spending the most time, and I have found it very effective for non-trivial code. I would imagine it would give you the data that you need.