I would like to get the total time as given by the timeit module (so user + sys time) for a block of code that is executed many times in my script (it is inside a loop). I know the timeit module can give you these times by using %time [code here], but how do I do something like this for multiple lines of code?
So I would like to do something like:
# Some code here
x = start_time() # just something to mark the start of timing
# code I want to know the time of
user, system, elapsed = stop_time(x) # whatever marks the end of timing
This question is really much like the one here: Get time of execution of a block of code in Python 2.7 However in this case the person asking the question was mostly interested in elapsed time and so all answers tell how to do this. I have found many examples of how to do this but I would really like to get user and sys time.
I really hope someone can help me with this. Thanks in advance