Skip to main content

Measure execution time of code sections.

Project description

timerpy

Measure execution time of code sections.

Installation

python3 -m pip install timerpy

Usage Examples

from timerpy import Timer
with Timer():
    # Some code

>>>TIME ELAPSED: 0:00:01.199748


# Specify message
with Timer('HELLO WORLD'):
    # Some code

>>>HELLO WORLD TIME ELAPSED: 0:02:15.242731


# Specify output
from logging import info # Write to log file
with Timer('HELLO WORLD', info):
    # Some code

>>>timer.py: INFO: stop(): 44:	HELLO WORLD TIME ELAPSED: 0:00:01.200157


# Get elapsed time as float value
with Timer() as timer1:
    # Some code
seconds = timer1.elapsed_time
print(seconds)

>>>TIME ELAPSED: 0:00:01.399406
>>>1.3994057

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

timerpy-1.0.3.tar.gz (2.0 kB view hashes)

Uploaded Source

Built Distribution

timerpy-1.0.3-py3-none-any.whl (3.2 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