Skip to main content

Conveniently measure and compare the execution times of multiple statements.

Project description

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                                                                    

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.1.tar.gz (11.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: timeit_compare-1.4.1.tar.gz
  • Upload date:
  • Size: 11.2 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.1.tar.gz
Algorithm Hash digest
SHA256 a460302df8979b430a4aef3c11671ba4c563707f27e1b78b69c6b65d6700f560
MD5 3ead22674f95ca8f2fb36bd3c68ca21c
BLAKE2b-256 37814c7cf5292860a315dfef4686aba8f5db4fdf862fa683e911a9a523363ab1

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