Skip to main content

Python code performace metrics calculation tool

Project description

Perfwatch

Perfwatch is a python package that allows you to monitor the performance of your code. It is designed to be used in a Jupyter notebook, but can also be used in a Python script.

Table of Contents

Installation

To install perfwatch, run the following command:

pip install perfwatch

Development

To install perfwatch for development, clone the repository and run the following command:

poetry install

To setup pre-commit hooks, run the following command:

poetry run pre-commit install

To run the tests, run the following command:

poetry run pytest

Usage

Available Profiler Types

The profiler supports the following profiler types:

  • cpu: Profiles CPU usage using the cProfile module.
  • memory: Profiles memory usage using the memory_profiler module.
  • thread: Profiles thread creation and usage.
  • io: Profiles I/O operations.
  • network: Profiles network traffic using the NetworkProfiler class.
  • gpu: Profiles GPU usage using the GPUProfiler class.
  • cache: Profiles cache performance (not implemented).
  • exception: Profiles exception handling (not implemented).
  • system: Profiles system performance (not implemented).
  • distributed: Profiles distributed system performance (not implemented).
  • line: Profiles line-by-line execution using the line_profiler module.
  • time: Profiles execution time.

Basic Usage

from perfwatch import watch

@watch(["line", "cpu", "time"])
def test():
    for _ in range(1000000):
        pass

if __name__ == "__main__":
    test()

Customizing Profiling

You can customize the profiling behavior by passing additional keyword arguments to the watch decorator. For example:

@watch("network", packet_src="localhost")
def my_function(x, y):
    # function implementation
    pass

Logging

The Profiler Service uses a logger to output profiling results. You can specify a log file path using the log_file_path keyword argument:

@watch("cpu", log_file_path="profiling.log")
def my_function(x, y):
    # function implementation
    pass

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

perfwatch-1.4.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

perfwatch-1.4.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file perfwatch-1.4.2.tar.gz.

File metadata

  • Download URL: perfwatch-1.4.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure

File hashes

Hashes for perfwatch-1.4.2.tar.gz
Algorithm Hash digest
SHA256 e2dea919d88202503ddb7809d54e03b6031ccafd72a83faaed0ba9fa1a2ff57a
MD5 1cd4695ae3f62fde70e7ef3354bfbe1a
BLAKE2b-256 b457b7af308ab71596812d30d03dbcafc12765b5b3721f5c19a2a2de44b2b206

See more details on using hashes here.

File details

Details for the file perfwatch-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: perfwatch-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure

File hashes

Hashes for perfwatch-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3fb08254270aef20b82a61d699c5ffdd1ef60706b50bdc20123f9e6498429c01
MD5 5d0166ee27b2f6c0d8834a973b7ef59a
BLAKE2b-256 b534fcc9979fa87c95ea92b923fa2f9f1badaf4a4a9727796aad6c372bd54803

See more details on using hashes here.

Supported by

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