Simplified performance timers in Python.
Project description
Perfed
Perfed is a simplified approach to performance timing in Python.
Usage
import time
from perfed.timers import Timers
timers = Timers()
timers.start("first")
time.sleep(0.2)
timers.stop("first")
timers.start("second")
time.sleep(0.3)
timers.stop("second")
with timers.start("third"):
time.sleep(0.4)
timers.show()
"""
Output:
Timer Elasped Time
------- --------------
first 0.200766
second 0.301181
third 0.400664
------CSV-----
Timer,Elasped Time
first,0.200766
second,0.301181
third,0.4006642
"""
import time
from perfed.timer_decorator import TimerDecorator
@TimerDecorator.decorate("foo_timer")
def foo(x: int):
print(x)
time.sleep(0.2)
@TimerDecorator.decorate("bar_timer")
def bar(x: str):
print(x)
time.sleep(0.3)
foo(49)
foo(200)
foo(455)
bar("cat")
bar("dog")
TimerDecorator.get_manager("foo_timer").show()
print(TimerDecorator.get_manager("foo_timer").average())
TimerDecorator.get_manager("bar_timer").show()
print(TimerDecorator.get_manager("bar_timer").average())
"""
Output:
49
200
455
cat
dog
Timer Elasped Time
------------ --------------
foo_timer(1) 0.200183
foo_timer(2) 0.200126
foo_timer(3) 0.200508
0.20027236666666665
Timer Elasped Time
------------ --------------
bar_timer(1) 0.300116
bar_timer(2) 0.300573
0.3003445
"""
Credit
This is heavily inspired by perfcounters. I decided to create this repository as I have some original ideas and would like to try my hand at making my own Python package.
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
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 perfed-0.1.0.tar.gz.
File metadata
- Download URL: perfed-0.1.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e9de400aa72dc0cf6f38d26f1282941aba9f9fe4ec787144155b808ffc50274
|
|
| MD5 |
020d01059d2c7e4d80f286246f2e1332
|
|
| BLAKE2b-256 |
82950b5fc6d26d462d2e9d67f941a561bd90547204386d0cc1c9456283686a9a
|
Provenance
The following attestation bundles were made for perfed-0.1.0.tar.gz:
Publisher:
publish.yaml on sohenze/perfed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perfed-0.1.0.tar.gz -
Subject digest:
5e9de400aa72dc0cf6f38d26f1282941aba9f9fe4ec787144155b808ffc50274 - Sigstore transparency entry: 228285976
- Sigstore integration time:
-
Permalink:
sohenze/perfed@d5ef6d77f0209912b65b6bbe769145708cf21b17 -
Branch / Tag:
refs/tags/perfed-v0.1.0 - Owner: https://github.com/sohenze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@d5ef6d77f0209912b65b6bbe769145708cf21b17 -
Trigger Event:
release
-
Statement type:
File details
Details for the file perfed-0.1.0-py3-none-any.whl.
File metadata
- Download URL: perfed-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8a310ef0cc52ef03cb32a86cfef22eab8195cc66920965966ff77895b82ae0e
|
|
| MD5 |
60b67c0930f5ce934233f65b073ad238
|
|
| BLAKE2b-256 |
edad8af4ea181a7e85781858807ca402cd77bfa0659203988fab59ced324ab6e
|
Provenance
The following attestation bundles were made for perfed-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on sohenze/perfed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perfed-0.1.0-py3-none-any.whl -
Subject digest:
b8a310ef0cc52ef03cb32a86cfef22eab8195cc66920965966ff77895b82ae0e - Sigstore transparency entry: 228285980
- Sigstore integration time:
-
Permalink:
sohenze/perfed@d5ef6d77f0209912b65b6bbe769145708cf21b17 -
Branch / Tag:
refs/tags/perfed-v0.1.0 - Owner: https://github.com/sohenze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@d5ef6d77f0209912b65b6bbe769145708cf21b17 -
Trigger Event:
release
-
Statement type: