Files
NexQuant/rdagent/log/time.py
T
WinstonLiyt a2d86f2efe feat: Add runtime measurement for each step and loop in RDLoop. (#281)
* Add runtime measurement for each step and loop in RDLoop.

* refine some codes

* refine the code (#276)

* show variables only when it exists (#277)

* fix: support seed and fix absolute path (#278)

* fix: support seed and fix absolute path

* Absolute path

* lint

* fix: improve_execution_time_in_kaggle_loop (#279)

* improve_execution_time_in_kaggle_loop

* fix CI

* fix CI

* fix CI

* fix: Update runner.py to fix a small bug (#282)

* fix: Update runner.py to fix a small bug

* fix CI

* refine the code

* Update loop.py

* Update rd_loop.py

* Update model_xgb.py

---------

Co-authored-by: XianBW <36835909+XianBW@users.noreply.github.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
Co-authored-by: Xu Yang <peteryang@vip.qq.com>
2024-09-20 16:05:59 +08:00

20 lines
525 B
Python

import time
from functools import wraps
from rdagent.log import rdagent_logger as logger
def measure_time(method):
@wraps(method)
def timed(*args, **kwargs):
start_time = time.time()
result = method(*args, **kwargs)
end_time = time.time()
duration = end_time - start_time
method_name = method.__name__
# logger.log_object(f"{method_name} took {duration:.2f} sec")
logger.info(f"{method_name} took {duration:.2f} sec")
return result
return timed