Skip to main content

Conveniently measure and compare the execution time of multiple statements.

Project description

timeit_compare

Conveniently measure and compare the execution time 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 compare
>>> 
>>> compare(
...     "'-'.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 1. Comparison Results (unit: s)                              
╭────┬───────────────────────────┬──────────────────────────┬────────┬────────┬────────┬────────╮
│ Id │           Stmt            │          Mean ↓          │ Median │  Min   │  Max   │  Std   │
├────┼───────────────────────────┼────────┬───────┬─────────┼────────┼────────┼────────┼────────┤
│ 1  │ '-'.join([str(n) for n i… │ 6.2e-6 │ 75.3% │ █████▎  │ 6.2e-6 │ 6.2e-6 │ 6.3e-6 │ 3.2e-8 │
│ 2  │ '-'.join(map(str, range(… │ 7.2e-6 │ 87.4% │ ██████▏ │ 7.2e-6 │ 7.2e-6 │ 7.3e-6 │ 2.3e-8 │
│ 0  │ '-'.join(str(n) for n in… │ 8.3e-6 │ 100.% │ ███████ │ 8.3e-6 │ 8.2e-6 │ 8.3e-6 │ 2.3e-8 │
╰────┴───────────────────────────┴────────┴───────┴─────────┴────────┴────────┴────────┴────────╯
7 runs, 9894 loops each, total time 1.504s                                                       

The table shows some basic descriptive statistics on the execution time of each statement for comparison, including mean, median, minimum, maximum, and standard deviation.

In a command line interface, call as follows:

python -m timeit_compare -a "'-'.join(str(n) for n in range(100))" -a "'-'.join([str(n) for n in range(100)])" -a "'-'.join(map(str, range(100)))"

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

timeit_compare-1.3.1.tar.gz (11.6 kB view details)

Uploaded Source

File details

Details for the file timeit_compare-1.3.1.tar.gz.

File metadata

  • Download URL: timeit_compare-1.3.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for timeit_compare-1.3.1.tar.gz
Algorithm Hash digest
SHA256 e72d2f3648b522bf9fc6d63e9c5b0f53640b7ab864a830e5730903a14eb7c0b0
MD5 ef0c8ad5e8b592264b461b4e6e8e914e
BLAKE2b-256 6b2ed414d105a8125500b2bcf764998da68a6dda92533005d538259f0792c8f1

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