ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 27 Feb 2018 11:08:14 -0600How to properly time Sage computations?http://ask.sagemath.org/question/41284/how-to-properly-time-sage-computations/I have written a Sage code that performs some calculations with elliptic curves, and I want to get how much time it took to finish the calculations. I saw that there is already a function called [timeit](https://doc.sagemath.org/html/en/reference/misc/sage/misc/sage_timeit_class.html), but what I see is that it basically times the given command. Instead what I need is that I want to time the execution of certain code block (for example, a loop). Assuming, I have a code segment as this:
for i in range(0, 100):
# Do some calculations...
How can I get how much time it took to execute the code block (in this case the whole loop)?ninhoTue, 27 Feb 2018 11:08:14 -0600http://ask.sagemath.org/question/41284/Timing cached functionshttp://ask.sagemath.org/question/8289/timing-cached-functions/I have defined a recursive function that call itself several times, often asking for the same result that was previously computed. In this setting, defining the function as cached makes perfect sense.
But when i try to timeit, i always get very low timings (i assume the function is computed once and then the cache is called several times, making the average timing very low). I could define the function as non cached, but in that case i can not measure how much i gain by caching the intermediate calls from the function to itself.
Is there some way to say timeit to empty the cache each time the function is run?mmarcoTue, 23 Aug 2011 07:01:45 -0500http://ask.sagemath.org/question/8289/