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.2.tar.gz (3.2 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.2-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logprof-0.1.2.tar.gz
  • Upload date:
  • Size: 3.2 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.2.tar.gz
Algorithm Hash digest
SHA256 2176c301787ccc3eafb2845a11f298cf6139cd400d75568a50c3b2f2894cc402
MD5 940789e0cd3f9170f7cf4da638763415
BLAKE2b-256 3e24311999a9d7d7ab87018538195a917653a7fc5ec0137213a6473cc67b9f5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for logprof-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: logprof-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c47b2d88c397d4b8745eb7e66b0f5b4239c42129567d1a2fc799ce9e73125ae
MD5 cf273a537697a122d30aeeabad511cce
BLAKE2b-256 5f1e1f128ce51b51be4869a070c01d659a6f45d7059bd3dad3a747670a940c92

See more details on using hashes here.

Provenance

The following attestation bundles were made for logprof-0.1.2-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