timing¶
Provides Matlab-like tic, tac and toc functions.
- quantecon.util.timing.loop_timer(n, function, args=None, verbose=True, digits=2, best_of=3)[source]¶
Return and print the total and average time elapsed for n runs of function.
- Parameters:
- nscalar(int)
Number of runs.
- functionfunction
Function to be timed.
- argslist, optional(default=None)
Arguments of the function.
- verbosebool, optional(default=True)
If True, then prints average time.
- digitsscalar(int), optional(default=2)
Number of digits printed for time elapsed.
- best_ofscalar(int), optional(default=3)
Average time over best_of runs.
- Returns:
- average_timescalar(float)
Average time elapsed for n runs of function.
- average_of_bestscalar(float)
Average of best_of times for n runs of function.
- quantecon.util.timing.tac(verbose=True, digits=2)[source]¶
Return and print elapsed time since last tic(), tac(), or toc().
- Parameters:
- verbosebool, optional(default=True)
If True, then prints time.
- digitsscalar(int), optional(default=2)
Number of digits printed for time elapsed.
- Returns:
- elapsedscalar(float)
Time elapsed since last tic(), tac(), or toc().
- quantecon.util.timing.toc(verbose=True, digits=2)[source]¶
Return and print time elapsed since last tic().
- Parameters:
- verbosebool, optional(default=True)
If True, then prints time.
- digitsscalar(int), optional(default=2)
Number of digits printed for time elapsed.
- Returns:
- elapsedscalar(float)
Time elapsed since last tic().