-2

At the first glance, Python documentation at https://docs.python.org/3.10/library/timeit.html# suggests that the time units returned by timeit with default parameters are the ones of the default timer time.perf_counter(), which are fractional seconds. I couldn't find anything to the contrary on that page, but a simple test:

>>> timeit('3**2')
0.007580029021482915

suggests usec. What have I missed?

Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
  • **timeit(number=1000000)** Time number executions of the main statement. This executes the setup statement once, and then returns the time it takes to execute the main statement a number of times, **measured in seconds as a float.** [its seconds as documented here](https://docs.python.org/3.10/library/timeit.html#timeit.Timer.timeit) – Patrick Artner Sep 07 '21 at 16:26

1 Answers1

2

It's seconds. You missed that that's the time for the default one million executions (number=1000000).

no comment
  • 6,381
  • 4
  • 12
  • 30