timeit
The timeit module is used to time simple Python code.
Timer ([statement [, setup [, timer]]])
Creates a Timer object. statement is a string containing a Python statement to be timed. setup is an optional string containing a Python statement that is executed prior to the timing of statement. timer is a platform-specific timing function such as time.time() or time.clock() in the time module. Normally, this does not need to be supplied.
An instance, t, of Timer has the following methods:
t.print_exc([file])
Prints execution information for exceptions that occur in timed code. To use this, enclose the timeit() method in a try block and use print_exc in an except clause.
t.repeat([repeat [, number]))
Executes the timeit() method multiple ...
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.