Timeprint
Python context manager and decorator for showing time elapsed.
Setup
pip install timeprint
Usage as a context manager
import timeprint
with timeprint:
do_stuff()
# it took 100ms
with timeprint('some stuff')
do_stuff()
# some stuff took 100ms
Usage as a decorator
import timeprint
@timeprint
def first_function():
do_stuff()
# first_function took 100ms
@timeprint('some other stuff')
def second_function():
do_stuff()
# some other stuff took 100ms
Is that it?
Yes. I was tired of finding and copying my old Gist into files every time I wanted to measure a small chunk of code.