A usefull timer package to measure and pack functions' execution time.
Project description
timer-python
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
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 Distributions
Built Distribution
File details
Details for the file jdutimer-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: jdutimer-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04b05054733e13f34cabdb6b0eb4049e868ebe0ac496e7e74a969d2b2e63a907 |
|
MD5 | 0a79a54c627e2c76774b0eecb9f837cc |
|
BLAKE2b-256 | f4f3d99c2a8e38cc3818852b0f6b44b978539847fb997127208605b179a58009 |