Conveniently get a rough idea of how long things take.
Project description
magic-timer
pip install magic-timer
A simple timer, for conveniently getting a rough idea of how long things take.
This is not for precision / accuracy; for that use something like timeit.
This package basically just makes timing with time.monotic() fractionally more convenient.
This package is not recommended for measuring sub 100 millisecond times.
Output is in an appropriate unit, rounded to two significant figures. Note that 3 digit numbers are also rounded to 2 sig figs, e.g. 231 -> 240.
Use via decorator:
from magic_timer import MagicTimer, magic_timer
import time
@magic_timer
def some_slow_function():
time.sleep(2.75)
some_slow_function()
> 'some_slow_function' - 2.8 seconds
Use via MagicTimer object:
def some_slow_function():
time.sleep(90/1000)
timer = MagicTimer()
some_slow_function()
print(timer)
> 95 milliseconds
See also this notebook.
The use case: you have a function you want to time, but you don't want to time it multiple times with timeit
,
and you don't want to use Jupyter %%timeit
because %%timeit
puts the cell into a different scope.
You can import magic-timer
, throw it on, and get a rough idea of the elapsed time.
This is somewhat of a pico-package...
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
Built Distribution
File details
Details for the file magic-timer-0.0.11.tar.gz
.
File metadata
- Download URL: magic-timer-0.0.11.tar.gz
- Upload date:
- Size: 3.4 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.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d551de5efa30a5556d51d952bae1e15dde70d228fb174ccb080bc15a128cbf |
|
MD5 | 8f7d3195c5c6062d0390139cf3cb165b |
|
BLAKE2b-256 | 88d068fb8471ab9d6205605a02b1bc59680faaa11114bad34339133745ec6cf8 |
File details
Details for the file magic_timer-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: magic_timer-0.0.11-py3-none-any.whl
- Upload date:
- Size: 5.1 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.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 011ae7ea1a408306c03cf5d9e9773988407cb86f24d2f0a74f803d1625e0710d |
|
MD5 | 1fbbd8ea96bb0cf52f7546cce65a2e6c |
|
BLAKE2b-256 | f337c6db45a3d4abb843d505d764382b794b856f5179ee65b65f5825fa23faa5 |