measure / limit execution time using with-statements or decorators, cross-platform
Project description
timework
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
Release history Release notifications | RSS feed
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.3.tar.gz
(4.9 kB
view hashes)