Created
May 17, 2017 01:40
-
-
Save rsp2k/0cc0c01ebc946f53587962d93d26dac5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 time | |
def timing_function(some_function): | |
""" | |
Outputs the time a function takes | |
to execute. | |
""" | |
def wrapper(): | |
t1 = time.time() | |
some_function() | |
t2 = time.time() | |
return "Time it took to run the function: " + str((t2 - t1)) + "\n" | |
return wrapper | |
@timing_function | |
def my_function(): | |
num_list = [] | |
for num in (range(0, 10000)): | |
num_list.append(num) | |
print("\nSum of all the numbers: " + str((sum(num_list)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment