Skip to content

Instantly share code, notes, and snippets.

@ZGainsforth
Last active August 29, 2015 14:03
Show Gist options
  • Save ZGainsforth/66738546bedd17e9306b to your computer and use it in GitHub Desktop.
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.
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