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.1.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: stoppy-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 4d3d182e6d6ee037e121e7feac2badb4f0fd52729e8b674e89313731c68844e1
MD5 30cc945036d157f62e15278117461e04
BLAKE2b-256 a4bf67a40c41815684941493b3c271bd49dd0ea8111150f39dccf6fd1d7f8c33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stoppy-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c5e7a442002c96b11f00bde7efa0a2b76529f74c70badfc633ae2e4c1513168
MD5 3932c577b2d6670b3c26e51cb0f89fbf
BLAKE2b-256 f2a96ae5aad767d9a369392a4ef1f3f57de5990c2457da2f827965f8ad18c93b

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