Skip to main content

AI-enabled time and memory profiler for Python applications

Project description

Zero-Hassle AI Enabled Python Profiler for Time & Memory

AI enabled lightweight time and memory profiler for Python, zero-configuration python profiler that captures function-level performance metrics along with analysis of function implementation with AI Agent with no code changes. Ideal for:

  • Python scripts
  • Flask projects
  • Real-time debugging of performance bottlenecks

Features

Zero Code Changes

Just run your Python script — no decorators, annotations, or modifications needed.

Time & Memory Metrics

Automatically captures:

  • Max execution time (CPU)
  • Peak memory usage
  • RSS memory growth
  • Return object size
  • Arguments passed

Project-Aware Analysis

Only your code is profiled.
System libraries and external modules are ignored using intelligent project-path detection.

Profiler Metrics

The following table describes the metrics collected by the profiler:

Metric Description Key
Function Name The name of the function being profiled. function
File Path The absolute path to the file where the function is defined. file
Line Number The line number where the function starts in the file. line
Execution Time Maximum time taken by each function in milliseconds (ms). max_time_ms
CPU Time Time spent by the CPU on this function (ms). cpu_time_ms
Peak Memory Usage Maximum memory usage during function execution in kilobytes (KB). max_mem
RSS Memory Growth Growth in Resident Set Size (RSS) memory in kilobytes (KB), helps spot memory leaks. mem_growth_rss_kb
Arguments The arguments passed to the function being profiled. args
Possible Memory Leak Indicates if a potential memory leak is detected (if any). possible_memory_leak
Notes Any additional notes related to the profiling data. note
Returned Object Size The size of the returned object in bytes. return_obj

Option to select a function for analysis, which is analysed by the Ollama model installed and configured. This is the table providing the options for analysis.

Available Functions for Analysis

Index Function Name File Path
0 function_one /path/to/file_one.py
1 function_two /path/to/file_two.py
2 function_three /path/to/file_three.py
3 function_four /path/to/file_four.py
4 function_five /path/to/file_five.py
... ... ...
N function_n /path/to/file_n.py
N+1 Skip Analysis -

Structured JSON Reports

Each function includes:

  • Function name
  • Source file and line number
  • Time (ms)
  • Memory usage (KB)
  • Return object size
  • Arguments
  • Memory growth & potential leaks

Works with Any Project Structure

Handles nested folder hierarchies easily — just point to your project root and go.


Setup Instructions

1. Set Environment Variables

export PROFILER_FILE_PATH="/absolute/path/to/your_script.py"
export PROFILER_DIR_PATH="/absolute/path/to/your/project/root"

If you just want to try, you can test it with sample_project.

export PROFILER_FILE_PATH="$(pwd)/sample_project/inside/app.py": The Python file to be profiled
export PROFILER_DIR_PATH="$(pwd)/sample_project/inside": Root of your project for accurate filtering

2. Optional: Suppress Console Output

By default, profiler prints a table to the console. To disable:

export CONSOLE_DISPLAY=False

Environment Setup

This will install the requirements in your env

If you don't have a virtual environment, just install the dependencies:

profile_code

This will create an env and install requirements

LLM Environment Setup

Download Ollama from Ollama

ollama run <yout_model>

If you don't know which model to use.

ollama run deepseek-r1:1.5b: It is preferable as it is light weight.

Set your model env variable.

export AGENT_NAME="<your_model>"
export AGENTIC_PROFILER=True

This will:

  • Read the env vars
  • Launch your script
  • Record memory + execution stats
  • Save detailed JSON report

Supported Use Cases

  • Pure Python projects
  • Flask APIs and apps
  • Any directory layout

Want More?

  • Console table toggle
  • HTML report output
  • Jupyter Notebook integration

Pull requests are welcome!

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

aipymemtimeprofiler-0.4.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

aipymemtimeprofiler-0.4.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file aipymemtimeprofiler-0.4.0.tar.gz.

File metadata

  • Download URL: aipymemtimeprofiler-0.4.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for aipymemtimeprofiler-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c4e41122e530fcd83aea8c97c16ff94a7ae0a5f883acc0421bad44b4ecb46254
MD5 cda81f7dbb6b21e77746406bcdc1dc97
BLAKE2b-256 760e2905ce124346cbfe6ab48e5934980345e5250190bb2c58781a88853174b4

See more details on using hashes here.

File details

Details for the file aipymemtimeprofiler-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aipymemtimeprofiler-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15b7344f79a55549300c85ecdb44fd067579499fad08340d284e59720817f0a8
MD5 63ea1f37e5b052eda5ab23957d5f9307
BLAKE2b-256 b623d7414fc1173c86a9b451ace309ce23a13689ad7c2277f8800a001ec6d63d

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