#pprof #cpu #flame-graph

scuffle-pprof

Helper crate for adding pprof support to your application

8 releases

Uses new Rust 2024

new 0.1.4 May 17, 2025
0.1.3 May 15, 2025
0.1.2 Apr 27, 2025
0.1.1 Feb 21, 2025
0.0.0 Nov 28, 2024

#137 in Profiling

Download history 94/week @ 2025-02-03 262/week @ 2025-02-10 162/week @ 2025-02-17 33/week @ 2025-02-24 33/week @ 2025-03-03 13/week @ 2025-03-10 11/week @ 2025-03-17 2/week @ 2025-03-24 6/week @ 2025-04-07 1/week @ 2025-04-14 70/week @ 2025-04-21 66/week @ 2025-04-28 18/week @ 2025-05-05 329/week @ 2025-05-12

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

MIT/Apache

16KB
81 lines

scuffle-pprof

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

License: MIT OR Apache-2.0 docs.rs crates.io GitHub Actions: ci Codecov


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.

See the changelog for a full release history.

Feature flags

  • docs — Enables changelog and documentation of feature flags

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

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

~11–23MB
~371K SLoC