Skip to main content

Indicates progress during runtime, while keeping track of time consumed by user-defined tasks.

Project description

https://travis-ci.com/sigvaldm/TaskTimer.svg?branch=master https://coveralls.io/repos/github/sigvaldm/TaskTimer/badge.svg?branch=master https://img.shields.io/pypi/pyversions/TaskTimer.svg

Indicates progress during runtime, while keeping track of time consumed by user-defined tasks. Not quite a progress bar, not quite a profiler, but something in between which I personally have found to be very handy, especially when working with computationally intensive programs.

Consider this simple dummy program:

from tasktimer import TaskTimer
from time import sleep

timer = TaskTimer()

for n in timer.range(40):

    timer.task('Assembling load vector (b)')
    sleep(0.1) # Dummy

    timer.task('Solving linear system Au=b')
    sleep(0.5) # Dummy

print(timer)

The task() method is used to indicate that from now on the program is working on another task. TaskTimer will indicate progress, and display the current task, for instance:

Step 11/40 (28%). 17.5s of 24.1s remaining. Assembling load vector (b)

When all tasks are completed, print(timer) can be used to print statistics of the tasks:

                             #   Mean   StDev  Total    %
Assembling load vector (b)  40  101ms  89.2us  4.02s   17
Solving linear system Au=b  40  501ms   140us  20.0s   83
Total                                          24.1s  100

Many more options than demonstrated here are available, and the functionality is extensively documented in the docstrings. For instance, customization of the progress string (see TaskTimer), iterating over general iterables using the iterate() method, sorting the statistics (see the summary() method). The time tracking of the individual tasks are performed by the Timer class, which can also be used stand-alone.

Installation

Install from PyPI using pip:

pip install TaskTimer

Or download the GitHub repository https://github.com/sigvaldm/TaskTimer.git and run:

python setup.py install

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

tasktimer-1.0.4.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file tasktimer-1.0.4.tar.gz.

File metadata

  • Download URL: tasktimer-1.0.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.2 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0a4+

File hashes

Hashes for tasktimer-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7a06453597ee5d779ea4163bf5ba4430bf8097003738f044d6b02f83f4a98478
MD5 6442237cb4c92dc6b02863de524a0a50
BLAKE2b-256 318d6722accfd312e52e71cb061457215ed864f5c3c3eed9ad90e3b744868ca1

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