Automatic commit performed through alias...

This commit is contained in:
Shaun Setlock
2020-04-14 20:47:43 -04:00
parent 7c5a186c6f
commit efac2d7cc8

View File

@@ -8,27 +8,20 @@
#
# Find the sum of all the multiples of 3 or 5 below 1000.
import functools
def f_timer(passed_f):
def inner_f(*args, **kwargs):
import time
t1 = time.time()
value = passed_f(*args, **kwargs)
t2 = time.time()
t3 = t2 - t1
print("The function {} ran for {:4f} seconds... ".format(passed_f.__name__,t3))
return value
def timer(f):
""" Decorator function to calculate compute time of passed function. """
@functools.wraps(f)
def wrapper_timer(*args,**kwargs):
start_time = time.perf_counter()
f(*args, **kwargs)
end_time = time.perf_counter()
run_time = end_time - start_time
print("Finished {func.__name__!r} in {run_time:.4f} seconds...")
return f
return wrapper_timer
return inner_f
def check_divisibility(num, dict_multiples: dict) -> bool:
@@ -41,7 +34,7 @@ def check_divisibility(num, dict_multiples: dict) -> bool:
else:
return False
@timer
@f_timer
def main():
multiples = {3,5}