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


Keywords
decorators, python, with-statement
License
MIT
Install
pip install timework==0.2.9

Documentation

timework

pypi codefactor coverage 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