Jump to content

Python: Difference between revisions

208 bytes added ,  26 April 2020
Line 170: Line 170:


===Timing Code===
===Timing Code===
[https://stackoverflow.com/questions/2866380/how-can-i-time-a-code-segment-for-testing-performance-with-pythons-timeit Reference]
[https://stackoverflow.com/questions/2866380/how-can-i-time-a-code-segment-for-testing-performance-with-pythons-timeit StackOverflow]<br>
[https://docs.python.org/3/library/time.html Python Time Documentation]
 
* <code>time.time()</code> return the seconds since epoch as a float
* You can also use timeit to time over several iterations
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
import time
import time