Last active
August 29, 2015 14:03
-
-
Save ZGainsforth/66738546bedd17e9306b to your computer and use it in GitHub Desktop.
Simple use of the timeit module where you need to import a function or variable to time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(x): | |
x = x*3 | |
return x | |
import timeit | |
n = 100000 | |
print timeit.timeit(stmt='myfunc(5)', setup='from __main__ import myfunc', number=n)/n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment