File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
computing/scheduler/master Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 16
16
from ....core .mlops .mlops_utils import MLOpsUtils
17
17
from ..scheduler_core .log_manager import LogsManager
18
18
from ..scheduler_core .metrics_manager import MetricsManager
19
- from fedml .utils .debugging import debug
19
+ from fedml .utils .decorators import debug
20
20
from ..scheduler_core .status_center import JobStatus
21
21
from ..scheduler_core .compute_cache_manager import ComputeCacheManager
22
22
from multiprocessing import Process , Queue
Original file line number Diff line number Diff line change 1
1
from typing import Callable
2
2
import os
3
+ import time
3
4
import functools
4
5
5
- def debug (_func : Callable = None , * , output_file = "output.txt" ):
6
6
7
+ def debug (_func : Callable = None , * , output_file = "output.txt" ):
7
8
def decorator (func : Callable ):
8
9
9
10
@functools .wraps (func )
@@ -36,3 +37,16 @@ def wrapper(*args, **kwargs):
36
37
return decorator
37
38
38
39
return decorator (_func )
40
+
41
+ def timeit (func : Callable ):
42
+ """Print the runtime of the decorated function"""
43
+ functools .wraps (func )
44
+
45
+ def wrapper (* args , ** kwargs ):
46
+ start = time .perf_counter ()
47
+ func (* args , ** kwargs )
48
+ end = time .perf_counter ()
49
+ run_time = end - start
50
+ print (f"Finished { func .__name__ !r} in { run_time :.4f} seconds" )
51
+
52
+ return wrapper
You can’t perform that action at this time.
0 commit comments