Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

timeit.timeit():

  • Measures the time taken to execute a given statement or function for a specified number of iterations.
  • The function takes arguments such as stmt, setup, number which determine the statement to be timed, setup to be executed before the timed code, and number of iterations to be performed.
  • Returns the time taken to execute the statement in seconds.

Timer.autorange():

  • Automatically determines the number of iterations that should be performed for a given statement to achieve more accurate timing results.
  • The function takes arguments such as stmt, setup which determine the statement to be timed and setup code to be executed.
  • Returns a tuple of two elements: the number of iterations determined by the function and the time taken to execute the statement in seconds for that number of iterations.