Metadata-Version: 2.4
Name: lblprof
Version: 0.1.8
Summary: Line by line terminal based profiler
Author-email: le-codeur-rapide <paul.vezia@gmail.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: matplotlib>=3.10.1; extra == "dev"
Requires-Dist: virtualenv>=20.30.0; extra == "dev"
Requires-Dist: pandas>=2.0.3; extra == "dev"
Requires-Dist: chromadb>=0.5.23; extra == "dev"
Requires-Dist: ruff>=0.3.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=24.2.0; extra == "dev"

# LBLProf

LBLProf is simple a line by line terminal based time profiler. It allows you to track the duration of each line and get a tree of the execution of the code.

It comes with a simple interactive terminal UI to navigate the tree and see the stats of each line.
Example of the terminal ui:

![Example of the terminal ui](./docs/terminalui_showcase.png)

> [!WARNING]
> LBLProf is a tool that is based on the sys.monitoring API that is available in Python 3.12 and above.
> **It means that you need to use Python 3.12 or above to use it.**

# Documentation

## Installation

```bash
pip install lblprof
```

The only dependency of this package is pydantic, the rest is standard library.


## Usage

This package contains 4 main functions:
- `start_tracing()`: Start the tracing of the code.
- `stop_tracing()`: Stop the tracing of the code, build the tree and compute stats
- `show_interactive_tree(min_time_s: float = 0.1)`: show the interactive duration tree in the terminal.
- `show_tree()`: print the tree to console.

```python
from lblprof import start_tracing, stop_tracing, show_interactive_tree, show_tree

start_tracing()

# Your code here (Any code)

stop_tracing()
show_tree() # print the tree to console
show_interactive_tree() # show the interactive tree in the terminal
```

## How it works

LBLProf is based on the sys.monitoring API that is available in Python 3.12 and above. [PEP 669](https://peps.python.org/pep-0669/)

This new API allow us to cut down tracing when we are entering installed package and limit the tracing to the code of the user.

