Skip to main content

A usefull timer package to measure and pack functions' execution time.

Project description

jdutimer

Singleton implementation of a timer. This package allows you to measure and summarize executions time.

Installation

> pip(3) install (-U) jdutimer

Methods

def add(self, func, *args)

... to measure the execution time of function.

def pack(self, title)

... to put all previous measured functions in a block with a given title.

def show_block(self, id=-1, unit="ms")

... to show execution time of a given block. The id can either be an integer, or a string. Display unit (s, ds, cs, ms) can be modified.

def show(self, unit="ms")

... to show all execution time blocks. Display unit (s, ds, cs, ms) can be modified.

def rename(self, old, new)

... to rename a given block. old can be the id or the name of the block to rename, new has to be a string.

Example usage

This snippet :

from jdutimer.timer import Timer

def foo(str):
    print(str)

def bar(num):
    print(num)

timer = Timer()
timer.add(foo, "Hello World!")
timer.add(bar, 42)
timer.pack("Display")

timer.show()

Shows this in the console :

Hello World!
42
Display 
        foo        0.04ms
        bar        0.01ms
                   0.04ms
        -----
        TOTAL      0.04ms

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

jdutimer-0.2.4.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file jdutimer-0.2.4.tar.gz.

File metadata

  • Download URL: jdutimer-0.2.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for jdutimer-0.2.4.tar.gz
Algorithm Hash digest
SHA256 2528278eb011c8603789aee3697066300c3280caf454892fc3d35481a45c036a
MD5 b46503884886da96b243e0428eece902
BLAKE2b-256 bc4f34a3d46722a8bd6436813e126b24a55e78ce68cdc65947b61fafafa1fa7f

See more details on using hashes here.

Supported by

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