# tauri-plugin-profiling
A Tauri v2 plugin for CPU profiling with flamegraph generation.
Provides **actual CPU profiling** using sampling-based techniques, complementing `tauri-plugin-tracing` which provides span timing (wall-clock time including I/O waits).
| macOS/Linux | pprof-rs (SIGPROF) |
| Windows | SuspendThread + StackWalk64 |
## Installation
```toml
[dependencies]
tauri-plugin-profiling = { git = "https://github.com/fltsci/tauri-plugin-profiling" }
```
```bash
pnpm add @tauri-apps/plugin-profiling
```
## Usage
### Rust
```rust
use tauri_plugin_profiling::ProfilingExt;
tauri::Builder::default()
.plugin(tauri_plugin_profiling::init())
.setup(|app| {
app.start_cpu_profile()?;
// ... work ...
let result = app.stop_cpu_profile()?;
println!("Flamegraph: {:?}", result.flamegraph_path);
Ok(())
})
```
### JavaScript
```typescript
import { startCpuProfile, stopCpuProfile, withProfiling } from '@tauri-apps/plugin-profiling';
await startCpuProfile({ frequency: 100 });
await doExpensiveOperation();
const result = await stopCpuProfile();
// Or use the convenience wrapper
const { result, profile } = await withProfiling(async () => processData());
```
## License
MIT OR Apache-2.0