Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 554 Bytes

File metadata and controls

27 lines (20 loc) · 554 Bytes

pytime

A lightweight and easy-to-use library that facilitates runtime logging.

Retrieve the runtime of a chosen code chunk:

from pytime import inline_runtime, time

t1 = time()
... # Do stuff
rtime = inline_runtime(t1)
print(rtime)

Use the func_runtime decorator so that a function call always logs the runtime:

from pytime import func_runtime
from time import sleep

@func_runtime(unit='ms') # Default unit is 'ms', accepts 's' for seconds
def my_func():
    sleep(1)

my_func()
Terminal output: 'Runtime ms: 1006.91'