Skip to main content

measure / limit execution time using with-statements or decorators, cross-platform

Project description

timework

PyPI CodeFactor Coverage Status platform

measure / limit execution time using with-statements or decorators, cross-platform

Install

pip install timework

Usage

import timework as tw

Statement with

timework.Stopwatch

measure execution time

Example
with tw.Stopwatch() as s:
    s.split()
    s.stop()
    s.restart()
    s.pause()
    s.resume()
    s.get_sec()
    s.get_hms()
Functions
get_sec()  get_hms()  restart()  pause()
resume()   split()    stop()

Decorator @

timework.timer

measure execution time

Example
@tw.timer(logging.warning)
def your_function():
    ...
Arguments
output: A function object that specifies where to log messages.
        For example: print. timework.nil does not log messages.
detail: A boolean value, whether to print start and end time.
        This argument must be passed using keywords.

timework.limit

limit execution time

Example
@tw.limit(3)
def your_function():
    ...
Arguments
timeout: This argument sets the timeout limit of the decorated
         function. Once the run time of the process reaches
         [timeout] seconds but not yet finishes, then raise
         TimeoutException and stop the inner function.

License

MIT License © bugstop

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

timework-0.4.1.tar.gz (4.9 kB view hashes)

Uploaded source

Built Distribution

timework-0.4.1-py3-none-any.whl (6.4 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