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 1616from ....core .mlops .mlops_utils import MLOpsUtils
1717from ..scheduler_core .log_manager import LogsManager
1818from ..scheduler_core .metrics_manager import MetricsManager
19- from fedml .utils .debugging import debug
19+ from fedml .utils .decorators import debug
2020from ..scheduler_core .status_center import JobStatus
2121from ..scheduler_core .compute_cache_manager import ComputeCacheManager
2222from multiprocessing import Process , Queue
Original file line number Diff line number Diff line change 11from typing import Callable
22import os
3+ import time
34import functools
45
5- def debug (_func : Callable = None , * , output_file = "output.txt" ):
66
7+ def debug (_func : Callable = None , * , output_file = "output.txt" ):
78 def decorator (func : Callable ):
89
910 @functools .wraps (func )
@@ -36,3 +37,16 @@ def wrapper(*args, **kwargs):
3637 return decorator
3738
3839 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