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:
n : scalar(int)

Number of runs.

function : function

Function to be timed.

args : list, optional(default=None)

Arguments of the function.

verbose : bool, optional(default=True)

If True, then prints average time.

digits : scalar(int), optional(default=2)

Number of digits printed for time elapsed.

best_of : scalar(int), optional(default=3)

Average time over best_of runs.

Returns:
average_time : scalar(float)

Average time elapsed for n runs of function.

average_of_best : scalar(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:
verbose : bool, optional(default=True)

If True, then prints time.

digits : scalar(int), optional(default=2)

Number of digits printed for time elapsed.

Returns:
elapsed : scalar(float)

Time elapsed since last tic(), tac(), or toc().

quantecon.util.timing.tic()[source]

Save time for future use with tac() or toc().

quantecon.util.timing.toc(verbose=True, digits=2)[source]

Return and print time elapsed since last tic().

Parameters:
verbose : bool, optional(default=True)

If True, then prints time.

digits : scalar(int), optional(default=2)

Number of digits printed for time elapsed.

Returns:
elapsed : scalar(float)

Time elapsed since last tic().