The Python Oracle

How can I time a code segment for testing performance with Pythons timeit?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Horror Game Menu Looping

--

Chapters
00:00 Question
01:13 Accepted answer (Score 376)
02:21 Answer 2 (Score 62)
02:42 Answer 3 (Score 43)
04:01 Answer 4 (Score 15)
05:37 Thank you

--

Full question
https://stackoverflow.com/questions/2866...

Question links:
[timeit]: https://docs.python.org/2/library/timeit...

Accepted answer links:
[time.time()]: https://docs.python.org/3/library/time.h...
[time.clock()]: https://docs.python.org/3/library/time.h...
[timeit]: https://docs.python.org/3/library/timeit...

Answer 3 links:
[timeit.timeit]: http://docs.python.org/library/timeit.ht...

Answer 4 links:
[timeit.timeit()]: https://docs.python.org/2/library/timeit...
[timeit.default_timer()]: https://docs.python.org/2/library/timeit...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #testing #timeit #databasetuning

#avk47