diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-08-16 04:51:39 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-08-16 04:51:39 +0000 |
| commit | b0dd1bde531a90a867448c03ec08b72cc70f0053 (patch) | |
| tree | 0ec22360367159e8b928b030351d6a8b53f3ada4 /indoteknik_custom/models/performance_test.py | |
| parent | 9f8664c33429e41c6133ba2b325662245ffbc92d (diff) | |
| parent | a73c0825a264fc002e7496b07f238f79efd93086 (diff) | |
Merged in refactor (pull request #99)
Refactor
Diffstat (limited to 'indoteknik_custom/models/performance_test.py')
| -rw-r--r-- | indoteknik_custom/models/performance_test.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/indoteknik_custom/models/performance_test.py b/indoteknik_custom/models/performance_test.py new file mode 100644 index 00000000..1782eb9d --- /dev/null +++ b/indoteknik_custom/models/performance_test.py @@ -0,0 +1,20 @@ +import time, logging + +_logger = logging.getLogger(__name__) + +def performance_test(num_tests): + def decorator(func): + def wrapper(*args, **kwargs): + total_time = 0 + for _ in range(num_tests): + start_time = time.time() + result = func(*args, **kwargs) + end_time = time.time() + total_time += end_time - start_time + + average_time = total_time / num_tests + _logger.info(f"Average execution time over {num_tests} tests: {average_time:.6f} seconds") + return result + + return wrapper + return decorator |
