Olli Graf
1 month ago
1 changed files with 21 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||||
|
|
||||
|
import time |
||||
|
|
||||
|
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))}" |
||||
|
|
||||
|
|
||||
|
print(summe(1000000)) |
||||
|
|
Loading…
Reference in new issue