timeit_compare
Conveniently measure and compare the execution times of multiple statements.
Installation
To install the package, run the following command:
pip install timeit_compare
Usage
Here is a simple example from the timeit library documentation:
>>> from timeit_compare import cmp
>>> cmp(
... "'-'.join(str(n) for n in range(100))",
... "'-'.join([str(n) for n in range(100)])",
... "'-'.join(map(str, range(100)))"
... )
timing now...
|████████████| 21/21 completed
Table. Comparison Results (unit: s)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
Idx Mean ↓ Median Min Max Stdev Stmt
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 5.9e-6 75.7% █████▎ 5.9e-6 5.9e-6 6.0e-6 3.8e-8 '-'.join([str(n) for n in range(100)])
2 7.3e-6 93.4% ██████▌ 7.3e-6 7.2e-6 7.4e-6 7.6e-8 '-'.join(map(str, range(100)))
0 7.8e-6 100.% ███████ 7.8e-6 7.7e-6 8.0e-6 1.1e-7 '-'.join(str(n) for n in range(100))
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
7 runs, 10290 loops each, total time 1.509s
In a command line interface, call as follows:
python -m timeit_compare - "'-'.join(str(n) for n in range(100))" - "'-'.join([str(n) for n in range(100)])" - "'-'.join(map(str, range(100)))"
help
usage: python -m timeit_compare [-h] [-v] [- STMT [STMT ...]] [-s [SETUP ...]] [-r REPEAT] [-n NUMBER] [-t TOTAL_TIME] [-w WARMUPS] [--no-progress] [--sort-by {mean,median,min,max,stdev}]
[--no-sort] [--reverse] [-p PRECISION] [--percentage [{mean,median,min,max,stdev} ...]] [-f FILE]
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-, --stmt STMT [STMT ...]
statement to be timed. A multi-line statement can be given by passing multiple strings simultaneously in an argument
-s, --setup [SETUP ...]
statement to be executed once initially for the last --stmt argument, if there are no --stmt arguments before this, it indicates the default setup statement for all --stmt
(default: 'pass'). A multi-line statement is processed in the same way as --stmt
-r, --repeat REPEAT how many times to repeat the timers (default: 7)
-n, --number NUMBER how many times to execute statement (default: estimated by -t)
-t, --total-time TOTAL_TIME
if specified and no -n greater than 0 is specified, it will be used to estimate a -n so that the total execution time (in seconds) of all statements is approximately equal
to this value (default: 1.5)
-w, --warmups WARMUPS
how many times to warm up the timers (default: 1)
--no-progress no progress bar
--sort-by {mean,median,min,max,stdev}
statistic for sorting the results (default: 'mean')
--no-sort do not sort the results
--reverse sort the results in descending order
-p, --precision PRECISION
digits precision of the results, ranging from 1 to 8 (default: 2)
--percentage [{mean,median,min,max,stdev} ...]
statistics showing percentage (default: same as --sort-by)
-f, --file FILE prints the results to a stream (default: the current sys.stdout)
Metadata
Release files for timeit-compare 1.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| timeit_compare-1.4.3.tar.gz | 13.3 kB | Without provenance | Details for timeit_compare-1.4.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timeit_compare-1.4.3-py3-none-any.whl | Python 3 | none | any | Details for timeit_compare-1.4.3-py3-none-any.whl |
Total release size: 27.4 kB
Release files / timeit_compare-1.4.3.tar.gz
| Download URL | timeit_compare-1.4.3.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd0c6e49832f9f005e986d5b29e93eee5ee9335662fada27eedfcdfd60ca6ba8
|
|
BLAKE2b-256 checksum How to use checksums |
b90866eaab3fcb1dde082174e6dd1ed0d7b7efad9468cd156dd7e432ddc20dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / timeit_compare-1.4.3-py3-none-any.whl
| Download URL | timeit_compare-1.4.3-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ec0ea88f8ff13eb2d7c134960039f126fed125645305a235b94207e7b3c3f8c
|
|
BLAKE2b-256 checksum How to use checksums |
5979ab11507e38555ae7531d1445558520901c529636bd590344fe2b784f13cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Security for timeit-compare 1.4.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.