EmbarkStudios
puffin
Rust

๐Ÿฆ Friendly little instrumentation profiler for Rust ๐Ÿฆ€

Last updated Jul 6, 2026
1.7k
Stars
110
Forks
41
Issues
+3
Stars/day
Attention Score
83
Language breakdown
No language data available.
โ–ธ Files click to expand
README

๐Ÿฆ puffin

The friendly little instrumentation profiler for Rust

Puffin photo by Richard Bartz

(puffin photo by Richard Bartz)

Embark Embark Crates.io Docs dependency status Build Status

How to use

rust
fn my_function() {
    puffin::profile_function!();
    ...
    if ... {
        puffin::profilescope!("loadimage", image_name);
        ...
    }
}

The Puffin macros write data to a thread-local data stream. When the outermost scope of a thread is closed, the data stream is sent to a global profiler collector. The scopes are pretty light-weight, costing around 50-200 ns.

You have to turn on the profiler before it captures any data with a call to puffin::setscopeson(true);. When the profiler is off the profiler scope macros only has an overhead of 1 ns on an M1 MacBook Pro (plus some stack space).

Once per frame you need to call puffin::GlobalProfiler::lock().new_frame();.

Puffin Flamegraph using puffin</em>egui

Remote profiling

You can use puffinhttp to send profile events over TCP to puffinviewer. This is as easy as:

fn main() {
    let serveraddr = format!("127.0.0.1:{}", puffinhttp::DEFAULT_PORT);
    let puffinserver = puffinhttp::Server::new(&serveraddr).unwrap();
    eprintln!("Run this to view profiling data:  puffinviewer {serveraddr}");
    puffin::setscopeson(true);

โ€ฆ

// You also need to periodically call // puffin::GlobalProfiler::lock().new_frame(); // to flush the profiling events. }

egui integration

To view the profile data in-game you can use puffin_egui.

If you are using eframe you can look at this example.

Other

Also check out the crate profiling which provides a unifying layer of abstraction on top of puffin and other profiling crates.

Contributing

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started.

Releasing

We use the cargo release tool to manage changelogs, git tags and publishing crates.

Each substantial pull request should add a changelog entry under the [Unreleased] section (see keep a changelog and previous changelog entries). The crate version in Cargo.toml is never updated manually in a PR as it's handled by cargo release.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท EmbarkStudios/puffin ยท Updated daily from GitHub