David Blume commited on 2020-12-30 11:24:35
Showing 1 changed files, with 13 additions and 1 deletions.
| ... | ... |
@@ -5,11 +5,22 @@ |
| 5 | 5 |
import os |
| 6 | 6 |
import sys |
| 7 | 7 |
import time |
| 8 |
+import functools |
|
| 8 | 9 |
from argparse import ArgumentParser |
| 9 | 10 |
import counter.counter |
| 10 | 11 |
import sitesize.sitesize |
| 11 | 12 |
|
| 12 | 13 |
|
| 14 |
+def timeit(f): |
|
| 15 |
+ @functools.wraps(f) |
|
| 16 |
+ def wrapper(*args, **kwargs): |
|
| 17 |
+ s = time.time() |
|
| 18 |
+ r = f(*args, **kwargs) |
|
| 19 |
+ print(f'{f.__name__} took {time.time() - s:1.3f}s.')
|
|
| 20 |
+ return r |
|
| 21 |
+ return wrapper |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 13 | 24 |
def set_v_print(verbose: bool): |
| 14 | 25 |
""" |
| 15 | 26 |
Defines the function v_print. |
| ... | ... |
@@ -21,6 +32,7 @@ def set_v_print(verbose: bool): |
| 21 | 32 |
v_print = print if verbose else lambda *a, **k: None |
| 22 | 33 |
|
| 23 | 34 |
|
| 35 |
+@timeit |
|
| 24 | 36 |
def main(debug: bool): |
| 25 | 37 |
start_time = time.time() |
| 26 | 38 |
localdir = os.path.abspath(os.path.dirname(sys.argv[0])) |
| ... | ... |
@@ -28,7 +40,7 @@ def main(debug: bool): |
| 28 | 40 |
counter.counter.run() |
| 29 | 41 |
v_print("Running sitesize...")
|
| 30 | 42 |
sitesize.sitesize.run() |
| 31 |
- print(f'Done in {localdir}. That took {time.time() - start_time:1.2f}s.')
|
|
| 43 |
+ print(f'Done in {localdir}.')
|
|
| 32 | 44 |
|
| 33 | 45 |
|
| 34 | 46 |
if __name__ == '__main__': |
| 35 | 47 |