In many situations, developers may want to measure the running time of functions. The original Timer in LibMultiLabel is no more convenient than using the time package directly. The new lightweight timer is a decorator and is easy to use.
usage 1:
import time
from libmultilabel.common_utils import timer
@timer
def a ():
time.sleep(3)
a()
INFO:lightning.pytorch.utilities.rank_zero:Finished 'a' in 3.00 seconds
usage 2:
def a ():
time.sleep(3)
timer(a)()
INFO:lightning.pytorch.utilities.rank_zero:Finished 'a' in 3.00 seconds
Test CLI & API (bash tests/autotest.sh)
Test APIs used by main.py.
[x] Test Pass
(Copy and paste the last outputted line here.)
[ ] Not Applicable (i.e., the PR does not include API changes.)
Check API Document
If any new APIs are added, please check if the description of the APIs is added to API document.
[ ] Not Applicable (i.e., the PR does not include API changes.)
Test quickstart & API (bash tests/docs/test_changed_document.sh)
If any APIs in quickstarts or tutorials are modified, please run this test to check if the current examples can run correctly after the modified APIs are released.
What does this PR do?
In many situations, developers may want to measure the running time of functions. The original Timer in LibMultiLabel is no more convenient than using the time package directly. The new lightweight timer is a decorator and is easy to use.
usage 1:
usage 2:
Test CLI & API (
bash tests/autotest.sh
)Test APIs used by main.py.
Check API Document
If any new APIs are added, please check if the description of the APIs is added to API document.
Test quickstart & API (
bash tests/docs/test_changed_document.sh
)If any APIs in quickstarts or tutorials are modified, please run this test to check if the current examples can run correctly after the modified APIs are released.