skillfed

stopwatch.py

A simple stopwatch for python

stopwatch-py v2.0.1 190.1K downloads/30d#9,914 on PyPI25
Permissive license MIT DORMANT released

What it is and what it does

Stopwatch.py wraps Python's time.perf_counter() in a simple object-oriented interface for measuring elapsed time. It provides a Stopwatch class that can be instantiated, started, stopped, reset, and queried for the elapsed duration in seconds or as a formatted string. The package has no external dependencies and runs entirely in-process—there is no background task or thread; timing is purely mathematical arithmetic on the counter values.

The package is designed for straightforward use cases where you need to measure how long a code block or operation takes. You can control decimal precision when converting to a string representation, and the stopwatch can be paused and resumed. It is lightweight enough for quick instrumentation but offers no advanced features like lap timing, multiple concurrent timers, or statistical aggregation.

Use it for:

  • Measure execution time of a function or code block during development or debugging.
  • Track elapsed time in a game loop or animation to control frame timing.
  • Benchmark performance of different algorithms or implementations.
  • Monitor how long a background task or operation takes in a simple script.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a simple stopwatch timer that measures elapsed time using Python's high-resolution performance counter, with methods to start, stop, reset, and retrieve the duration.

Yes, if you need a minimal, dependency-free timer. The package is straightforward and well-suited for quick timing tasks. However, note that maintenance is dormant—no updates since 2022-09-04—so expect no bug fixes or Python version support beyond what is already declared. For production code or long-term projects, consider whether a more actively maintained alternative or Python's built-in timeit module better fits your needs.

Install

stopwatch-py on PyPI

pip

pip install stopwatch-py

uv

uv add stopwatch-py

poetry

poetry add stopwatch-py

Installing stopwatch.py

Before you install

Low install friction with no runtime dependencies. Dormant maintenance status since the latest release on 2022-09-04, though the repository remains active and unarchived.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open and closed-source projects.

Quickstart

pip install stopwatch.py

from stopwatch import Stopwatch

stopwatch = Stopwatch(2)
stopwatch.stop()
print(stopwatch.duration)

Requires Python 3.5 or later.

Verify before relying

  • Whether the package handles edge cases like repeated start/stop cycles or very long durations correctly.
  • Performance characteristics when timing very short intervals (microsecond-level precision).

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,440 days since the last release
Last repo commit
First released
Downloads 190,144/month — #9,914 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: stopwatch.py-2.0.1-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

python stopwatch timermeasure elapsed timesimple timing utilityperformance counter wrapperduration tracking
timingbenchmarking

More Utilities packages