Metadata-Version: 2.1
Name: py-stopwatch
Version: 0.2.0
Summary: Stopwatch class for timing portions of python code
Home-page: https://github.com/hrishikeshrt/py_stopwatch
Author: Hrishikesh Terdalkar
Author-email: hrishikeshrt@linuxmail.org
License: MIT license
Keywords: stopwatch
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.6
License-File: LICENSE
License-File: AUTHORS.rst

============
py-stopwatch
============

.. image:: https://img.shields.io/pypi/v/py-stopwatch?color=success
        :target: https://pypi.python.org/pypi/py_stopwatch

.. image:: https://readthedocs.org/projects/py-stopwatch/badge/?version=latest
        :target: https://py-stopwatch.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status

.. image:: https://img.shields.io/pypi/pyversions/py-stopwatch
        :target: https://pypi.python.org/pypi/py-stopwatch
        :alt: Python Version Support

.. image:: https://img.shields.io/github/issues/hrishikeshrt/py_stopwatch
        :target: https://github.com/hrishikeshrt/py_stopwatch/issues
        :alt: GitHub Issues

.. image:: https://img.shields.io/github/followers/hrishikeshrt?style=social
        :target: https://github.com/hrishikeshrt
        :alt: GitHub Followers

.. image:: https://img.shields.io/twitter/follow/hrishikeshrt?style=social
        :target: https://twitter.com/hrishikeshrt
        :alt: Twitter Followers


Stopwatch class for timing portions of python code.

* Free software: MIT license
* Documentation: https://py-stopwatch.readthedocs.io.


Features
========

* Tick-based stopwatch
* Support for Pause/Resume
* Support for multiple named-ticks
* Utility functions for time between different ticks
* No third party requirements.

Usage
=====

.. code-block:: python

    from stopwatch import Stopwatch
    t = Stopwatch()
    t.start()
    print("Started ..")
    time.sleep(0.24)
    print(f"t.tick(): {t.tick():.4f} seconds")
    time.sleep(0.48)
    print(f"t.tick(): {t.tick():.4f} seconds")
    time.sleep(0.16)
    print(f"t.tick('Named Tick-1'): {t.tick('Named Tick-1'):.4f} seconds")
    t.pause()
    print("Paused ..")
    time.sleep(0.12)
    t.resume()
    print("Resumed ..")
    print(f"t.last(): {t.last():.4f} seconds")
    time.sleep(0.12)
    print(f"t.tick(): {t.tick():.4f} seconds")
    time.sleep(0.12)
    print(f"t.tick('Named Tick-2'): {t.tick('Named Tick-2'):.4f} seconds")
    t.stop()
    print("Timer stopped.")
    print("---")
    print(f"Total pause: {t.time_paused:.2f} seconds.")
    print(f"Total runtime: {t.time_active:.2f} seconds.")
    print(f"Total time: {t.time_total:.2f} seconds.")
    tij = t.get_time_elapsed(start_key='Named Tick-1', end_key='Named Tick-2')
    print(f"Time between 'Named Tick-1' and 'Named Tick-2': {tij:.4f}")


History
=======

0.0.1 (2021-04-13)
------------------

* First release on PyPI.
