Skip to main content

Library for execution time measurement

Project description

TimeRun

TimeRun is a Python library for elapsed time measurement.

  • Measure elapsed time and format output in one line yet providing the highest resolution for time measurement
  • All in a single file with no dependencies other than Python Standard Library

Features

  • Elapsed Time Estimator
    • Measure elapsed time with sleep
    • Measure elapsed time without sleep
  • Elapsed Time Formatter
    • Format time into hours, minutes, seconds and nanoseconds
    • Hide days part if time is less than 1 day
  • Shortcut to Time Measurement
    • Measure elapsed time for a code block
    • Measure elapsed time for a function

Installation

Install TimeRun from Python Package Index

pip install timerun

Install TimeRun from Source Code

python setup.py install

Examples

Measure code block execution time

from timerun import time_code

with time_code('countdown'):
    n = 1e6
    while n > 0:
        n -= 1
countdown - 00:00:00.110983022

Measure function execution time

from timerun import time_func

@time_func
def countdown():
    n = 1e6
    while n > 0:
        n -= 1

countdown()
__main__.countdown - 00:00:00.069651527

License

This project is licensed under the MIT License - see the LICENSE file for details

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

timerun-0.1.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

timerun-0.1-py3-none-any.whl (3.8 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