Skip to content

Instantly share code, notes, and snippets.

@SteadBytes
Last active December 11, 2017 09:01
Show Gist options
  • Save SteadBytes/a77d7fed9b3f773fdf8b1ca96cd3f454 to your computer and use it in GitHub Desktop.
Save SteadBytes/a77d7fed9b3f773fdf8b1ca96cd3f454 to your computer and use it in GitHub Desktop.
Boilerplate code for using the timeit module within a python module
import timeit
def func(x):
pass
def func_2():
pass
def wrapper(func, *args, **kwargs):
def wrapper():
return func(*args, **kwargs)
return wrapper
# Function with args:
wrapped = wrapper(func, 'args_here')
print(timeit.timeit(wrapped,number=1000)
#Function without args:
print(timeit.timeit(func_2,number=1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment