Skip to main content

Stopwatch class for timing portions of python code

Project description

https://img.shields.io/pypi/v/py-stopwatch?color=success Documentation Status Python Version Support GitHub Issues GitHub Followers Twitter Followers

Stopwatch class for timing portions of python code.

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

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.time_elapsed(start_name='Named Tick-1', end_name='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.

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

py-stopwatch-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

py_stopwatch-0.1.1-py2.py3-none-any.whl (5.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file py-stopwatch-0.1.1.tar.gz.

File metadata

  • Download URL: py-stopwatch-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for py-stopwatch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 96d96b003c638edf7ee6696995226b9cabcb2f06d48bc8768d90b1d45284e9be
MD5 e172175645c76f74114bfb6d4d7f7ec6
BLAKE2b-256 7e5db89995750441f0ada5083335916f3073e14583f131ae234584d82c480712

See more details on using hashes here.

File details

Details for the file py_stopwatch-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: py_stopwatch-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for py_stopwatch-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 866d032cc3ec5938ef5379da5daaa00eb9000bb89af66be46cd51aea96cccdda
MD5 de05f40067a72608b56168cc40f4e27c
BLAKE2b-256 eb6d03aa812a3dc1a70c6d762c21b15b1a9304b9f529522b3946751735130732

See more details on using hashes here.

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