Skip to main content

Conveniently measure and compare the execution times 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 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 │           Stmt            │          Mean ↓          │ Median │    Min - Max    │ Stdev  │
├─────┼───────────────────────────┼────────┬───────┬─────────┼────────┼────────┬────────┼────────┤
│  1  │ '-'.join([str(n) for n i… │ 6.1e-6 │ 77.4% │ █████▍  │ 6.1e-6 │ 6.0e-6 │ 6.2e-6 │ 7.9e-8 │
│  2  │ '-'.join(map(str, range(… │ 7.4e-6 │ 94.3% │ ██████▋ │ 7.3e-6 │ 7.2e-6 │ 8.1e-6 │ 3.2e-7 │
│  0  │ '-'.join(str(n) for n in… │ 7.9e-6 │ 100.% │ ███████ │ 7.8e-6 │ 7.8e-6 │ 8.0e-6 │ 6.5e-8 │
╰─────┴───────────────────────────┴────────┴───────┴─────────┴────────┴────────┴────────┴────────╯
7 runs, 10057 loops each, total time 1.505s                                                       

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 - "'-'.join(str(n) for n in range(100))" - "'-'.join([str(n) for n in range(100)])" - "'-'.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.4.0.tar.gz (11.3 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for timeit_compare-1.4.0.tar.gz
Algorithm Hash digest
SHA256 ce95bf93f667a7e6437ecec0a9927fc7ba6e207c1d95dd6eb3d05c15f6810571
MD5 16b53346c30731157f945e252b55805e
BLAKE2b-256 e8d7285b221b251a783ca75205d2dc2474742d4f2e400def83cf77f6be1407ad

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