Skip to main content

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:

nox --session do-lint

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

logprof-0.1.1.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logprof-0.1.1-py3-none-any.whl (1.8 kB view details)

Uploaded Python 3

File details

Details for the file logprof-0.1.1.tar.gz.

File metadata

  • Download URL: logprof-0.1.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for logprof-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b79352754e615e68a509e2ea793b3c39b2233168518b8759af55fbdc6c610c9
MD5 f54e1c2fb5b28603ac349d1108cd68a4
BLAKE2b-256 2417eddc56b99d49cd743b5e3b0d486e4af573b20c39141a25bd8d74d035f8a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for logprof-0.1.1.tar.gz:

Publisher: release.yaml on bsdz/logprof

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logprof-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: logprof-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for logprof-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65ffed5a280e1956c6e9cd97cd8602d659c592ff68a6d6cb84d5a8fdb5ce509e
MD5 cb50fbfc736b92e08812b64ac8fe0c40
BLAKE2b-256 4c339d0868c646f698c476bf49b951c7366e3778db7fa9e6c781cafd63789a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for logprof-0.1.1-py3-none-any.whl:

Publisher: release.yaml on bsdz/logprof

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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