Simple logging profiler.
Project description
logprof - Simple logging profiler
Simple logging of timing and memory usage with decorator or context manager.
Installation
pip install logprof
Usage
Below is an example usage
import logging
from logprof import logprof
logging.basicConfig(level="INFO")
# tf can be seconds (default) or "full"
@logprof("bar", tf="breakdown")
def function():
print("The bit in the middle")
function()
# INFO:logprof:>>> 'bar' started..
# The bit in the middle
# INFO:logprof:<<< 'bar' finished. Took 15us 860ns
class Foo:
@logprof("class func", tf="nanoseconds")
def bar(self, x=1):
print(f"bar got x = {x}")
Foo().bar()
# INFO:logprof:>>> 'class func' started..
# bar got x = 1
# INFO:logprof:<<< 'class func' finished. Took 15339ns
with logprof("foo", tf="breakdown", mf="breakdown"):
from time import sleep
sleep(1)
x = [1] * 2**25 ## 256MB?
x.append(1000)
print("The bit in the middle")
# INFO:logprof:>>> 'foo' started..
# The bit in the middle
# INFO:logprof:<<< 'foo' finished. Took 1s 111ms 947us 614ns. Used 255mib 1004kib.
Development
Before commit run following format commands in project folder:
poetry run black .
poetry run isort . --profile black
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
logprof-0.1.0.tar.gz
(1.7 kB
view details)
Built Distribution
File details
Details for the file logprof-0.1.0.tar.gz
.
File metadata
- Download URL: logprof-0.1.0.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.4 Linux/5.15.0-73-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26f16d9926dbfb85806357b2e918553e092cd3a2de3edc675eabd638ef04a463 |
|
MD5 | 215a740d338df876015ea0fc88e931ad |
|
BLAKE2b-256 | b9f29bd89661945714da14ef0db6257c0cef9d0dc36ef52f72a35f196490bf8e |
File details
Details for the file logprof-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: logprof-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.4 Linux/5.15.0-73-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7973f05232df5518830b3ab376cd550bfe67952a1d61f43fc4002ae1443c8bd |
|
MD5 | 3b9b7e165307c44ddd4ed601b3adfc8d |
|
BLAKE2b-256 | 581229cbd430011032ce79a704f42d6a61cba6e9549fff95d89393b0133a2207 |