Skip to content

kephircheek/python-timeti

Repository files navigation

timeti

Serialize elapsed time of functions, loops and code blocks.

test PyPI version license: MIT code style: black

Experience

Install

pip install timeti

Usage

  • Profile function with decorator

    >>> @timeti.profiler
    ... def ultimative_question(*args, **kwargs):
    ...     sum(range(100_000))
    ... 
    >>> ultimative_question()
    Elapsed time of 'ultimative_question' function: 4 ms
  • Profile loop with wrap

    >>> for i in timeti.profiler(range(2)):
    ...     _ = sum(range(100_000))
    ... 
    Elapsed time of loop iteration 0: 4 ms
    Elapsed time of loop iteration 1: 3 ms
    Elapsed time of loop: 8 ms
  • Profile code blocks with context manager

    >>> with timeti.profiler():
    ...     _ = sum(range(100_000))
    ... 
    Elapsed time of block: 5 ms

Development

Install

pip install -e ".[dev]"

Run linters

  • Format Python code with black

    python -m black .
    
  • Check types with mypy

    python -m mypy .
    
  • Sort imports alphabetically with isort

    python -m isort .
    
  • Analyze Python docstring with pydocstyle

    python -m pydocstyle .
    

Run tests

  • Run tests

    python -m unittest discover -s tests  
    
  • Run doctests for clock face

    python -m doctest -v timeti/clockface.py  
    

About

Serialize elapsed time of functions, loops and code blocks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages