Skip to main content

Conveniently get a rough idea of how long things take.

Project description

magic-timer

pip install magic-timer

Conveniently get a rough idea of how long things take.

This is a light wrapper around the standard library's time.monotonic.

How to use:

Use via MagicTimer object:

from magic_timer import MagicTimer

def do_stuff():
    [i*i for i in range(5_000_000)]

timer = MagicTimer()
do_stuff()
print('Stuff took', timer)
> Stuff took 455 milliseconds

Use via ftimer decorator:

from magic_timer import ftimer

@ftimer
def do_stuff():
    [i*i for i in range(20_000_000)]

do_stuff()
> `do_stuff` ran in 1.9 seconds.

The use case for this package:

You have something you want to time, but you don't want to time it multiple times with timeit.

You also don't want to use Jupyter's %%timeit because it puts the cell into a different scope.

You can import magic-timer, throw it in, and get a rough idea of the time taken. (It's slightly neater than using time.monotonic directly.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for magic-timer, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size magic_timer-0.1.1-py2-none-any.whl (4.3 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size magic-timer-0.1.1.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page