Time utilities for Python code
Project description
Chronologger
Time utilities for Python1
Requirements
Requirements: Python >= 3.6
Use the Makefile targets to access most of the functionality: make install-dev
, make dbuild
, make drun
, make dstart
...
Otherwise...
Install
pip install git+https://git@github.com/francisco-perez-sorrosal/chronologger.git
Run the Simple Example
Docker
Clone the project...
git clone git@github.com:francisco-perez-sorrosal/chronologger.git
and then...
cd chronologger
docker build -f Dockerfile.example -t chronologger-example .
docker run -itd --name chronologger-example chronologger-example:latest
docker exec -it chronologger-example python simple_example.py
Local
After installing the package, just clone the project and execute example with:
git clone git@github.com:francisco-perez-sorrosal/chronologger.git ; cd chronologger
python examples/simple_example.py
or open your python environment/IDE and execute:
import time
from chronologger import Timer, TimeUnit, root_timer
# Example of decorator: This should report ~100ms each time that is called
@Timer(name="Foo method!", unit=TimeUnit.ms, simple_log=True)
def foo():
time.sleep(0.1)
def main():
# Example of explicit timer: This should report ~100ms
timer = Timer("Individual Timer", unit=TimeUnit.ms).start()
time.sleep(0.1)
timer.stop()
# Example of explicit context timer: This should report ~1s
with Timer(name="Test Loop!", unit=TimeUnit.s, simple_log=True) as timer:
for i in range(5):
time.sleep(0.1) # e.g. simulate IO
foo()
timer.mark("i_{}".format(i))
if __name__ == "__main__":
root_timer.label(" STARTING!!!")
main()
root_timer.label(" PRINTING TIME")
root_timer.print()
Development
Install:
make install-dev
Use other commands in the Makefile for extra functionality.
Docker
make dbuild
make drun
make dtests
Use other commands in the Makefile for extra functionality.
IDE (PyCharm) Docker Interpreter
Once you create the Docker image with make dbuild
you can specify the chronologger-dev:latest
image as a Ptyhon
Docker interpreter in IntelliJ/PyCharm for example.
1: Inspired by the blog post Python Timer Functions: Three Ways to Monitor Your Code by Geir Arne Hjelle
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file chronologger-0.0.0.dev23.tar.gz
.
File metadata
- Download URL: chronologger-0.0.0.dev23.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b026a193089521e68b057f04cde71597d3cfcf83142d1a7d7dabb5d9d3ba196 |
|
MD5 | dd171491e40c539ca4cabb27702d0281 |
|
BLAKE2b-256 | 2d36c463baca5f63e559bf2622f3e8bbcbef53767913327c2ccbf6e7e9f3b2bc |
File details
Details for the file chronologger-0.0.0.dev23-py3-none-any.whl
.
File metadata
- Download URL: chronologger-0.0.0.dev23-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 886d8c44aaf710cd9c718772a7cce780bb3d93f5528df4607df9a61e4e559b37 |
|
MD5 | 9a2f567aff87ebc2608790ac3a3c4acf |
|
BLAKE2b-256 | f7b875273115327dc03bc492fd1e96ee357e04bd6a1d9dd68f715bb57da67565 |