Skip to main content

No project description provided

Project description

PeekPy

PyPI - Version PyPI - Python Version

PeekPy is a lightweight Python library for collecting runtime statistics and profiling function calls.

  • ✅ Easy to integrate using decorators
  • ⏱️ Built-in analyzers like call counter and execution timer
  • 🧩 Extensible via custom analyzers
  • 📦 Production ready and configurable

Installation

pip install peekpy

Quick Start

from peekpy.core.analyzers.call_counter import CallCounter
from peekpy.core.analyzers.timer import TimerCount
from peekpy.storage import save_stats_to_file


enable()  # Enable PeekPy globally

@analyze(analyzers=[CallCounter(), Timer()])
def my_function(x, y):
    return x + y

my_function(3, 4)
my_function(1, 2)

print(manager.get_stats())  # Print collected stats
save_stats_to_file("stats.json")

Features

  • CallCounter → tracks how many times a function is called
  • Timer → measures execution time per call
  • StatsManager → central place to store and export stats
  • @analyze() → flexible and customizable decorator

Usage

@analyze Decorator

@analyze(analyzers=[CallCounter(), Timer()])
def your_function(): ...

Each analyzer must implement a .before() and .after() method, and inherits from BaseAnalyzer.

Enable or Disable Analysis Globally

from peekpy.config import enable, disable, is_enabled

enable()
# or
disable()

Exporting Statistics

All statistics are collected by the StatsManager singleton:

import peekpy
from peekpy.storage import save_stats_to_file


print(json.dumps(peekpy.get_stats(), indent=4))

save_stats_to_file("stats.json")

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

peekpy-0.1.0a2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

peekpy-0.1.0a2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file peekpy-0.1.0a2.tar.gz.

File metadata

  • Download URL: peekpy-0.1.0a2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.11.0-1015-azure

File hashes

Hashes for peekpy-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 33f60028616d4d649332a5779fb88350dc588c2457ab4c2f0e4486692de2939b
MD5 3c8c22dc33f18e640f9068aca99efc25
BLAKE2b-256 5ecb3a618fbda35feef159178bedaf47cfbefbb6c656bd581e2c134c5dee2b59

See more details on using hashes here.

File details

Details for the file peekpy-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: peekpy-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.11.0-1015-azure

File hashes

Hashes for peekpy-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1644ba01f8bf055b51d337d4157c6e6a26f54c958eecc49e53d8925d5031c31
MD5 9cb634ee57d6f704d380a5ebf02209af
BLAKE2b-256 62c6e5fa383142a24cf46f2352324259764d55b2dbbb5e23d0a71460cad2ed74

See more details on using hashes here.

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