24 lines
512 B
Python
24 lines
512 B
Python
from time import perf_counter as pfc
|
|
from functools import wraps
|
|
|
|
def timing(func):
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
start = pfc()
|
|
result = func(*args, **kwargs)
|
|
end = pfc()
|
|
print(f"Dauer: {end - start:.4f}s")
|
|
return result
|
|
return wrapper
|
|
|
|
|
|
@timing
|
|
def meine_funktion(n):
|
|
total = 0
|
|
for i in range(n):
|
|
total += i
|
|
return total
|
|
|
|
|
|
ergebnis = meine_funktion(1000000)
|
|
print("Ergebnis:", ergebnis) |