176 lines
7.6 KiB
Markdown
176 lines
7.6 KiB
Markdown
### Versione in Italiano (per `README.md`)
|
|
|
|
```markdown
|
|
# Python Profile Analyzer
|
|
|
|
Un'applicazione desktop GUI, cross-platform, per l'analisi visuale e interattiva dei dati di profiling `cProfile` di Python. Scritta in Python con Tkinter, questo strumento aiuta gli sviluppatori a identificare i colli di bottiglia nelle performance del loro codice in modo intuitivo e veloce.
|
|
|
|

|
|
*(Nota: Sostituisci `screenshot.png` con uno screenshot reale dell'applicazione)*
|
|
|
|
---
|
|
|
|
## Caratteristiche Principali
|
|
|
|
* **Esecuzione e Profiling Integrati**: Esegui il profiling di script o moduli Python direttamente dall'applicazione attraverso un gestore di profili di lancio facile da usare.
|
|
* **Viste Multiple e Interattive**: Analizza i dati attraverso diverse prospettive:
|
|
* **Vista Tabellare**: Una tabella dettagliata con i dati di `pstats`, ordinabile dinamicamente per colonna (numero di chiamate, tempo totale, tempo cumulativo, ecc.).
|
|
* **Vista Testuale**: L'output standard di `pstats` per un'analisi classica.
|
|
* **Vista a Grafo**: Una visualizzazione a grafo delle chiamate (call graph) generata con Graphviz per identificare visivamente i percorsi più "costosi".
|
|
* **Filtraggio Dinamico**: Cerca e isola rapidamente funzioni specifiche nella vista tabellare e testuale.
|
|
* **Analisi Dettagliata Callers/Callees**: Seleziona una funzione per vedere istantaneamente quali altre funzioni l'hanno chiamata (callers) e quali funzioni ha chiamato (callees).
|
|
* **Visualizzazione a Grafo Intelligente**: Il grafo delle chiamate usa un codice colore (da verde a rosso) per evidenziare le funzioni che consumano più tempo, rendendo i colli di bottiglia immediatamente evidenti. La soglia di visualizzazione è regolabile.
|
|
* **Gestione Profili di Lancio**: Salva e gestisci diverse configurazioni di esecuzione (percorso dello script, argomenti, interprete Python, ecc.) per riutilizzarle facilmente.
|
|
* **Esportazione Dati**: Esporta la vista tabellare (filtrata e ordinata) in un file CSV per analisi esterne o reportistica.
|
|
|
|
---
|
|
|
|
## Requisiti e Installazione
|
|
|
|
### 1. Clonare il Repository
|
|
```bash
|
|
git clone <URL_DEL_TUO_REPOSITORY_GITEA>
|
|
cd <NOME_DELLA_CARTELLA>
|
|
```
|
|
|
|
### 2. Dipendenze Python
|
|
È consigliabile creare un ambiente virtuale.
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # Su Windows: venv\Scripts\activate
|
|
```
|
|
Installa le librerie Python necessarie:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
Il file `requirements.txt` dovrebbe contenere:
|
|
```
|
|
graphviz
|
|
Pillow
|
|
```
|
|
|
|
### 3. Dipendenza Esterna: Graphviz
|
|
La **Vista a Grafo** richiede che il software **Graphviz** sia installato sul tuo sistema e che il suo eseguibile sia presente nel PATH. La libreria Python da sola non è sufficiente.
|
|
|
|
* **Linux (Debian/Ubuntu)**:
|
|
```bash
|
|
sudo apt-get update
|
|
sudo apt-get install graphviz
|
|
```
|
|
* **macOS (usando Homebrew)**:
|
|
```bash
|
|
brew install graphviz
|
|
```
|
|
* **Windows**:
|
|
1. Scarica l'installer dal [sito ufficiale di Graphviz](https://graphviz.org/download/).
|
|
2. Durante l'installazione, assicurati di selezionare l'opzione "Add Graphviz to the system PATH" (Aggiungi Graphviz al PATH di sistema).
|
|
|
|
> **Nota**: Se Graphviz non è installato, l'applicazione funzionerà comunque, ma la scheda "Graph View" sarà disabilitata.
|
|
|
|
---
|
|
|
|
## Utilizzo
|
|
|
|
Per avviare l'applicazione, esegui il modulo `profileanalyzer` dalla root del progetto:
|
|
```bash
|
|
python -m profileanalyzer
|
|
```
|
|
|
|
### Flusso di Lavoro Tipico
|
|
1. Clicca su **"Profile a Script..."** per aprire il Gestore Profili.
|
|
2. Crea un "New Profile", specifica il percorso dello script/modulo, gli argomenti e salva.
|
|
3. Seleziona il profilo creato e clicca su **"Run & Profile Selected"**.
|
|
4. L'applicazione eseguirà il tuo script e caricherà automaticamente i risultati del profiling.
|
|
5. Esplora i dati nelle viste **Table**, **Text** e **Graph**. Usa il filtro e l'ordinamento per analizzare i risultati.
|
|
6. In alternativa, usa **"Load Profile File..."** per analizzare un file `.prof` preesistente.
|
|
```
|
|
|
|
---
|
|
---
|
|
|
|
### Versione in Inglese (per `README.md`)
|
|
|
|
```markdown
|
|
# Python Profile Analyzer
|
|
|
|
A cross-platform GUI desktop application for visual and interactive analysis of Python's `cProfile` profiling data. Written in Python with Tkinter, this tool helps developers quickly and intuitively identify performance bottlenecks in their code.
|
|
|
|

|
|
*(Note: Replace `screenshot.png` with an actual screenshot of the application)*
|
|
|
|
---
|
|
|
|
## Key Features
|
|
|
|
* **Integrated Profiling Runner**: Profile Python scripts or modules directly from the application through an easy-to-use launch profile manager.
|
|
* **Multiple Interactive Views**: Analyze data from different perspectives:
|
|
* **Table View**: A detailed table of `pstats` data, dynamically sortable by any column (call count, total time, cumulative time, etc.).
|
|
* **Text View**: The standard `pstats` text output for a classic analysis.
|
|
* **Graph View**: A call graph visualization generated with Graphviz to visually identify the most expensive execution paths.
|
|
* **Dynamic Filtering**: Quickly search and isolate specific functions in the table and text views.
|
|
* **Detailed Caller/Callee Analysis**: Select any function to instantly see which other functions called it (callers) and which functions it called (callees).
|
|
* **Intelligent Graph Visualization**: The call graph is heat-mapped with colors (from green to red) to highlight functions that consume the most time, making bottlenecks immediately apparent. The node visibility threshold is adjustable.
|
|
* **Launch Profile Manager**: Save and manage different launch configurations (script path, arguments, Python interpreter, etc.) for easy reuse.
|
|
* **Data Export**: Export the current table view (filtered and sorted) to a CSV file for external analysis or reporting.
|
|
|
|
---
|
|
|
|
## Requirements and Installation
|
|
|
|
### 1. Clone the Repository
|
|
```bash
|
|
git clone <YOUR_GITEA_REPOSITORY_URL>
|
|
cd <PROJECT_FOLDER_NAME>
|
|
```
|
|
|
|
### 2. Python Dependencies
|
|
It is highly recommended to use a virtual environment.
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
```
|
|
Install the required Python libraries:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
Your `requirements.txt` file should contain:
|
|
```
|
|
graphviz
|
|
Pillow
|
|
```
|
|
|
|
### 3. External Dependency: Graphviz
|
|
The **Graph View** feature requires the **Graphviz** software to be installed on your system and its executable to be in the system's PATH. The Python library alone is not sufficient.
|
|
|
|
* **Linux (Debian/Ubuntu)**:
|
|
```bash
|
|
sudo apt-get update
|
|
sudo apt-get install graphviz
|
|
```
|
|
* **macOS (using Homebrew)**:
|
|
```bash
|
|
brew install graphviz
|
|
```
|
|
* **Windows**:
|
|
1. Download the installer from the [official Graphviz website](https://graphviz.org/download/).
|
|
2. During installation, make sure to check the option "Add Graphviz to the system PATH".
|
|
|
|
> **Note**: If Graphviz is not installed, the application will still run, but the "Graph View" tab will be disabled.
|
|
|
|
---
|
|
|
|
## Usage
|
|
|
|
To launch the application, run the `profileanalyzer` module from the project's root directory:
|
|
```bash
|
|
python -m profileanalyzer
|
|
```
|
|
|
|
### Typical Workflow
|
|
1. Click **"Profile a Script..."** to open the Launch Manager.
|
|
2. Create a "New Profile", specify the script/module path, arguments, and save it.
|
|
3. Select the created profile and click **"Run & Profile Selected"**.
|
|
4. The application will run your script and automatically load the profiling results.
|
|
5. Explore the data in the **Table**, **Text**, and **Graph** views. Use the filter and sort controls to analyze the results.
|
|
6. Alternatively, use **"Load Profile File..."** to analyze a pre-existing `.prof` file.
|
|
``` |