Skip to main content

Simple timer for Python.

Project description

timer.py

Installation

pip install timerpy

Usage

from time import sleep
from timerpy import Timer

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

# 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('Timer stopped')
# Output:
# [Timer stopped] 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-1.2.1.tar.gz (2.8 kB view hashes)

Uploaded source

Built Distribution

timer.py-1.2.1-py3-none-any.whl (16.0 kB view hashes)

Uploaded py3

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