Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.
/ python-timework Public archive

measure / limit execution time using with-statements or decorators

License

Notifications You must be signed in to change notification settings

muhac/python-timework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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