This module provides a context manager for measuring execution times:
>>> from timethis import timethis
>>> with timethis('computing large sum'):
... x = sum(range(10**7))
...
computing large sum: 0.203 seconds
Usage of timethis can be nested:
>>> with timethis('figuring things out'):
... with timethis('computing large sum'):
... x = sum(range(10**7))
... with timethis('finding some primes'):
... y = [2] + [i for i in range(3, 10**4) if all(i % j != 0 for j in range(2, i // 2 + 1))]
...
│ computing large sum: 0.205 seconds
│ finding some primes: 0.305 seconds
figuring things out: 0.510 seconds
It's easy to use (for example) logging instead of print:
>>> import logging
>>> with timethis('computing large sum', logging.warning):
... x = sum(range(10**7))
...
WARNING:root:computing large sum: 0.218 seconds
Metadata
Release files for timethis 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| timethis-0.1.2.tar.gz | 2.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| timethis-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.7 kB
Release files / timethis-0.1.2.tar.gz
| Download URL | timethis-0.1.2.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0da79fb6b89a1ed9301a504d482da17abb39ade8f586d058189f89a18016c674
|
|
BLAKE2b-256 checksum How to use checksums |
e00bebe949cfd5cf02d99394d4e05f91ff2b5b4c6d3c4cb34fd117909f26fdf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.7
|
Release files / timethis-0.1.2-py3-none-any.whl
| Download URL | timethis-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ac55530f765ac7a50c7baf68a4108fa7221f88a14a62556447d0be1255cb5c4
|
|
BLAKE2b-256 checksum How to use checksums |
7a48cbd384059ad448fc73f2aa8b6348e368d2889bd94bf5493aae6baa2d780c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.7
|