Skip to main content

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

Project description

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

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.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timework-0.4.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file timework-0.4.3.tar.gz.

File metadata

  • Download URL: timework-0.4.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for timework-0.4.3.tar.gz
Algorithm Hash digest
SHA256 633fc71a8f275cb7aaa7c269caf49b21786fb0d13a11164c3de5fc98d94f73f2
MD5 f6b12568cec9c007ed23a7df77b1e9cd
BLAKE2b-256 83dafd0a7f2ee332aa3a0047eea9c8109b118db374f7e19656af0ee00b58fcc4

See more details on using hashes here.

File details

Details for the file timework-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: timework-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for timework-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b898dc8d979617535361086d32b8c40a839bdafa03c731529e57b8ac44966db4
MD5 b61cf9eec86cc8db9a20ac4ebf534508
BLAKE2b-256 d7820f675c7e90abca241ae606466f3e4a3733561637a104fa60e08cedfab9bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page