You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
499 B
29 lines
499 B
4 weeks ago
|
#Datei: timer.py
|
||
1 month ago
|
|
||
4 weeks ago
|
from fib import fib
|
||
|
from counter import counter
|
||
1 month ago
|
import time
|
||
4 weeks ago
|
import sys
|
||
1 month ago
|
|
||
|
def timer(func):
|
||
|
def wrapper(*args, **kwargs):
|
||
|
start_time = time.time()
|
||
|
|
||
|
result = func(*args,**kwargs)
|
||
|
|
||
|
end_time = time.time()
|
||
|
print(f'Methode {func.__name__} - Laufzeit {end_time - start_time:.4f}s')
|
||
|
return result
|
||
|
return wrapper
|
||
|
|
||
|
@timer
|
||
|
def summe(n):
|
||
|
return f"Summe: {sum(range(n))}"
|
||
|
|
||
4 weeks ago
|
@timer
|
||
|
def calc_fib(n):
|
||
|
return fib(n)
|
||
1 month ago
|
|
||
|
print(summe(1000000))
|
||
4 weeks ago
|
print(calc_fib(int(sys.argv[1])))
|