Last active
December 11, 2017 09:01
-
-
Save SteadBytes/a77d7fed9b3f773fdf8b1ca96cd3f454 to your computer and use it in GitHub Desktop.
Boilerplate code for using the timeit module within a python module
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
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