Skip to main content

A (BSD licensed) context manager for timing execution.

Project description

A (BSD licensed) context manager for timing execution. Useful for benchmarking everyday Python code easily/cleanly.

Usage

Usage is trivial. Simply wrap your code in a Timer context manager. Example:

from chrono import Timer

with Timer() as timed:
    # Put whatever logic you want here.
    # ``for`` loops are great here for timing things that are very fast.

print("Time spent: {0} seconds".format(timed.elapsed))

Requirements

  • Python 2.6+ or Python 3.3+ (may work on Python 2.5)

License

BSD

Docs

http://chrono-bench.readthedocs.org/en/latest/

Shortcomings

This is implemented in pure Python, so it doesn’t have the accuracy a C extension would have. There’s also overhead for the context manager function calls, so don’t use this to bench C code.

That said, for most everyday usage of Python, it’s very helpful.

Running Tests

Setup:

$ git clone https://github.com/toastdriven/chrono.git
$ cd chrono
$ virtualenv -p python3 env3
$ . env3/bin/activate
$ pip install nose

Running:

$ nosetests -s -v tests.py

chrono is maintained with 100% passing tests at all times.

Changelog

Dev
  • Added links to the docs

v1.0.1
  • Added initial docs

  • Fixed up the main docstring in Timer

v1.0.0
  • Initial release

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

chrono-1.0.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

chrono-1.0.2-py2.py3-none-any.whl (4.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file chrono-1.0.2.tar.gz.

File metadata

  • Download URL: chrono-1.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for chrono-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4bf8daa17229cd6df6ef59a96e6c43b845a1df94555190a3117505815685198c
MD5 347daa2a079dc245ab2b439102315ae4
BLAKE2b-256 94a8eb47ef906a298d6f40bb46fd91289237e547210c9d61aa8008bf5925140b

See more details on using hashes here.

Provenance

File details

Details for the file chrono-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for chrono-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 91c0905cafe915579984ac18c8da631301391e44e9102945eefeadb8498af84b
MD5 f6bb1d57ec10efaa3f8ea6f87abc2473
BLAKE2b-256 be2f40c7dfa0de23a60b7e6e493bb471240688eb4e728eaadef53e1a184334c5

See more details on using hashes here.

Provenance

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