https://github.com/toastdriven/chrono
A (BSD licensed) context manager for timing execution.
https://github.com/toastdriven/chrono
Last synced: 11 months ago
JSON representation
A (BSD licensed) context manager for timing execution.
- Host: GitHub
- URL: https://github.com/toastdriven/chrono
- Owner: toastdriven
- License: bsd-3-clause
- Created: 2013-10-30T08:11:59.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-03T09:42:44.000Z (over 12 years ago)
- Last Synced: 2025-06-07T16:54:56.127Z (11 months ago)
- Language: Python
- Homepage: http://chrono-bench.readthedocs.org/en/latest/
- Size: 133 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
======
chrono
======
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
*
v1.0.2
* Added wheel integration
* Added a fallback for unittest2
* Added TravisCI integration
* Added links to the docs
v1.0.1
* Added initial docs
* Fixed up the main docstring in ``Timer``
v1.0.0
* Initial release