#pprof #cpu #flame-graph

scuffle-pprof

Helper crate for adding pprof support to your application

6 releases

Uses new Rust 2024

new 0.1.2 Apr 27, 2025
0.1.1 Feb 21, 2025
0.0.3 Feb 9, 2025
0.0.2 Dec 8, 2024
0.0.0 Nov 28, 2024

#152 in Profiling

Download history 41/week @ 2025-01-08 9/week @ 2025-01-15 9/week @ 2025-01-22 298/week @ 2025-02-05 70/week @ 2025-02-12 161/week @ 2025-02-19 43/week @ 2025-02-26 15/week @ 2025-03-05 17/week @ 2025-03-12 5/week @ 2025-03-19 1/week @ 2025-03-26 7/week @ 2025-04-09 114/week @ 2025-04-23

121 downloads per month
Used in scuffle-bootstrap-telemet…

MIT/Apache

14KB
69 lines

scuffle-pprof

[!WARNING]
This crate is under active development and may not be stable.

crates.io docs.rs


A crate designed to provide a more ergonomic interface to the pprof crate.

Only supports Unix-like systems. This crate will be empty on Windows.

Example

// Create a new CPU profiler with a sampling frequency of 1000 Hz and an empty ignore list.
let cpu = scuffle_pprof::Cpu::new::<String>(1000, &[]);

// Capture a pprof profile for 10 seconds.
// This call is blocking. It is recommended to run it in a separate thread.
let capture = cpu.capture(std::time::Duration::from_secs(10)).unwrap();

// Write the profile to a file.
std::fs::write("capture.pprof", capture).unwrap();

Analyzing the profile

The resulting profile can be analyzed using the pprof tool.

For example, to generate a flamegraph:

pprof -svg capture.pprof

Status

This crate is currently under development and is not yet stable.

Unit tests are not yet fully implemented. Use at your own risk.

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0

Dependencies

~9–20MB
~323K SLoC