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.

Source Distribution

magic-timer-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

magic_timer-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file magic-timer-0.1.0.tar.gz.

File metadata

  • Download URL: magic-timer-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

File hashes

Hashes for magic-timer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5822b378327ac787e8c800503431b1ec990b345cae31660b255304b5b0253e44
MD5 d9ab1bb24acb4fe612c06a789dbcfad8
BLAKE2b-256 bed796f70727a6e23b20e7b015d95801f54928987b362efa2e7ed9f5cf8a4590

See more details on using hashes here.

File details

Details for the file magic_timer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: magic_timer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

File hashes

Hashes for magic_timer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8b29525b35d1199802626c862fe29dae6af7300d7317261007b9443dd52fe0e
MD5 0be10b7ac02ca068fd4c3ac00ad9c4b6
BLAKE2b-256 44b14004739cb82507a8b12ccf0590c8add0144549e07337edf8668fce9b20a0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page