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.
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 |
Close
Hashes for magic_timer-0.1.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1afc4fe9e775c8976fb03775ee4faf014d52fafb4570818fb15080e432e0d7f3 |
|
MD5 | ce90b5f0a0529fb38dd5c224cc302fd0 |
|
BLAKE2-256 | 49f7b8720207fb776569116aad505473f9ad1785fcf1955893c481db4cad48d5 |