A very simple Python tool for process inspection and timer. (alpha)
Project description
Alpha
Deftimer is now alpha stage.
Throw me issues!
Environments
Python: >=3.6, <4
Requirements
pip install pathlib
Try deftimer with docker
$ cd <parent dir of deftimer>
$ docker build -t deftimer .
$ docker run --rm deftimer
deftimer
- quick start
It allows you to calculate run time of each functions. See USAGE.md for (more information)[https://github.com/hakumizuki/deftimer/blob/main/USAGE.md]
timer = Timer()
@timer.use_timer
def do_something():
...
do_something() # this prints the results
document
Timer(user='', description='')
Initialize a Timer instance first.
You will use the instance to decorate a function, use other methods.
timer = Timer()
@timer.use_timer
def something():
...
-
@timer.use_timer(detail=True)decorator
This decorator allows the function to be inspected by a timer instance.
params
detail: It shows full results when detail is True. -
timer.pause() & timer.resume()
You will sandwitch a process to omit the process from timer counting.
The process time occured between pause&resume will not be counted as a result.
@timer.use_timer
def something():
timer.pause()
time.sleep(5)
timer.resume()
The result will be 0 sec.
timer.block(name=None, exclude=True)context manager
params
name: You can name the block. The name will show up in results.
exclude: You can choose whether or not you exclude the process time that took to run the block from results.
@timer.use_timer
def something():
with timer.block(name='sleep_2sec_1'):
time.sleep(2)
timer.stop()
Use this when you want to stop the timer.
@timer.use_timer
def something():
timer.stop()
# any process after stop() will be excluded from results.
- Results
(TBD)
Below is an example of full results.
-----------------------------------------
Result --> 4.0531158447265625e-06 s
Whole program ran in --> 4.0531158447265625e-06 s
Paused --> 0 s, 0times
Blocks --> 0 blocks: []
Paused + Blocked --> 0 s
-----------------------------------------
- coming soon...
File exporting (JSON, CSV)
Average calculation
Test deftimer
$ docker run --rm deftimer python -m unittest
Note: It might fail depending on your pc spec.
Author
- Taichi Masuyama
- montanha.masu536@gmail.com
I always welcome your ideas!
Thanks for visiting my repo :)
License
"deftimer" is under MIT license
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deftimer-0.0.3.tar.gz.
File metadata
- Download URL: deftimer-0.0.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be72c1e9f2470aa78f8e542abf314fd86e9161e76f5fb15e6d5ac087a7608c59
|
|
| MD5 |
7916a318cd258cccb5f662c376b01545
|
|
| BLAKE2b-256 |
f99747709b40ce90d20de9c368eb38d782f5b51b7296daef7015ccf0727f6674
|
File details
Details for the file deftimer-0.0.3-py3-none-any.whl.
File metadata
- Download URL: deftimer-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d01b89e4b80505fbf772c9c0df379f308e9a28616852f3bab97579911cd79361
|
|
| MD5 |
b27750c914a208c1432d8366d098cdfd
|
|
| BLAKE2b-256 |
ec1b5a09ffb738b742fcf54db5e8ca00534262ab06395c443349950f3a2da936
|