ASUS-AICS / LibMultiLabel

A library for multi-class and multi-label classification
MIT License
152 stars 30 forks source link

A Lighter Timer #350

Closed donglihe-hub closed 9 months ago

donglihe-hub commented 10 months ago

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:

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.

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.

Eleven1Liu commented 10 months ago

@Sinacam Review