2 unstable releases

0.3.0 Aug 25, 2020
0.2.0 Aug 10, 2020

#16 in Profiling

Download history 146/week @ 2020-08-10 319/week @ 2020-08-17 368/week @ 2020-08-24 543/week @ 2020-08-31 514/week @ 2020-09-07 663/week @ 2020-09-14 1191/week @ 2020-09-21

1,023 downloads per month
Used in puffin-imgui

MIT/Apache

33KB
711 lines

🐦 Puffin - The Friendly Little Profiler

Build Status Crates.io Docs Contributor Covenant Embark

Puffin photo by Richard Bartz

Puffin is an instrumentation profiler written in Rust where you opt-in to profile parts of you code:

fn my_function() {
    puffin::profile_function!():
    ...
    if ... {
        puffin::profile_scope_data!("load_image", 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 100-200 nanoseconds.

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

UI

If you want to view a nice flamegraph of your profile data, you can use the crate puffin-imgui in this repo. It looks like this:

Puffin Flamegraph UI

Other

Puffin photo by Richard Bartz

Contributing

We welcome community contributions to this project.

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

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.

Dependencies

~730KB
~13K SLoC