Skip to main content

Easy and accurate timer for Python.

Project description

timer.py

Installation

pip install timerpy

Usage

from time import sleep
from timer_py import Timer

timer = Timer('Some Title')
timer.start()
# Or:
# timer = Timer('Some Title').start()

# Some one-second process
sleep(1)

# Printing the elapsed time. The timer will continue to run.
timer.elapsed()
# Output:
# [Some Title] 00:00:01.004

# Pause the timer
timer.pause()

# Process that won't be counted
sleep(1)

# Resume the timer
timer.resume()

# Another one-second process
sleep(1)

# Overriding the tag
timer.elapsed('Checkpoint 1')
# Output:
# [Checkpoint 1] 00:00:02.013

# Storing the elapsed time to a variable while hiding the output
elapsed = timer.elapsed(print=False)
print(elapsed)
# Output:
# 2.0134578000000003

# Stop the timer
timer.stop()
# Output:
# [Some Title] 00:00:02.013

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

timer.py-2.1.0.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

timer.py-2.1.0-py3-none-any.whl (18.0 kB view hashes)

Uploaded Python 3

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