added
This commit is contained in:
1 parent
9252eb99e3
commit
ab28089063
5 files changed
+140
No files matched your search
@@ -0,0 +1,28 @@
|
||||
from functools import wraps
|
||||
import time
|
||||
|
||||
|
||||
def timing(func):
|
||||
"""Decorator zur Messung der Ausführungszeit einer Funktion."""
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
start_time = time.perf_counter()
|
||||
result = func(*args, **kwargs)
|
||||
end_time = time.perf_counter()
|
||||
elapsed = end_time - start_time
|
||||
print(f"[{func.__name__}] Laufzeit: {elapsed:.6f} Sekunden")
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
from timing import timing
|
||||
|
||||
|
||||
@timing
|
||||
def beispiel_funktion():
|
||||
"""Dies ist eine Testfunktion."""
|
||||
pass
|
||||
|
||||
|
||||
help(beispiel_funktion)
|
||||
Reference in new issue
Block a user