Skip to main content

A precise and lightweight stopwatch built on top of `perf_counter`. Stopwatch can be used as a direct replacement for `perf_counter` that returns absolute timing starting from zero.

Project description

stoppy ⏱

A precise and lightweight stopwatch built on top of perf_counter. Stopwatch can be used as a direct replacement for perf_counter that returns absolute timing starting from zero.

The stopwatch can optionally be started automatically by calling time instead of start, which can streamline usage when polling the time repeatedly.

Installation

Install from PyPI via:

pip install stoppy

Usage

Basic usage is as follows:

from time import sleep
from stoppy import Stopwatch

with Stopwatch(start=True) as stopwatch:
    sleep(0.1)
    stopwatch.stop()
    print(stopwatch.time())
    stopwatch.reset()

It can also be used as a direct replacement for perf_counter with absolute timing starting from zero.

from stoppy import Stopwatch

with Stopwatch() as stopwatch:
    # Calling `stopwatch.time(True)` is equivalent to calling `perf_counter`, but starts from exactly zero
    print(stopwatch.time(True))

For all usage examples see examples/.

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

stoppy-1.0.2.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

stoppy-1.0.2-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file stoppy-1.0.2.tar.gz.

File metadata

  • Download URL: stoppy-1.0.2.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0

File hashes

Hashes for stoppy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3f5ec0371b53b0285e1faf9e670dca63ed2336cc6627eb803d4b746b612564c6
MD5 40935394ae00f6adfe89923bb15e38d2
BLAKE2b-256 ee15f30f18197cba60dd0563eb66e271064db986dd33045f6d9bcc223b9bc30a

See more details on using hashes here.

File details

Details for the file stoppy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: stoppy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0

File hashes

Hashes for stoppy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05dc2df1673f91f5b7065f5f8de2ae511848c7173efeb71f8f7a0a959b3740e1
MD5 383ff1b4de6f84c81ad85c5539bdae1a
BLAKE2b-256 8d6412451b9d685862dabb3e02090c3e02aa4c6295bf30c908d78ed894e0403e

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