Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 453 Bytes

README.md

File metadata and controls

24 lines (19 loc) · 453 Bytes

time-it

Short snippet to log a function's duration and keyword arguments

Usage exemple

import time
from helpers import log_duration # Assuming the script is located in a helpers file


@log_duration
def sleeper(duration: int):
    print('Good night 😴')
    time.sleep(duration)
    print('Wake up ⏰')
    return 'Done!'

print(sleeper(duration=5))
#  >>>
# Good night 😴
# Wake up ⏰
# 5.00s for sleeper duration: 5
# Done!