Apache License 2.0

项目介绍

EmbarkStudios/puffin 是一个托管在 GitHub 上的开源项目,主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前获得 1.8k 个 Star、111 次 Fork。

仓库全名
EmbarkStudios/puffin
开源许可证
Apache License 2.0
Star 数
1.8k
Fork 数
111
未关闭 Issue
28

README 摘要

🐦 puffin The friendly little instrumentation profiler for Rust (puffin photo by Richard Bartz) How to use 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…

完整内容见 GitHub 原始 README 或本页 。

常见问题

puffin 用什么语言开发?

主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前有 1.8k 个 Star。

puffin 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 puffin 的源码?

可以直接克隆仓库:git clone https://github.com/EmbarkStudios/puffin.git,默认分支为 main;安装与运行步骤见仓库 README。

puffin 最近还在维护吗?

仓库最近一次更新为 1 周前,当前有 28 个未关闭 Issue;Star 数为 1.8k,可作为社区活跃度的参考。

简要分析

热度分
1996
价值分
1089
活跃状态
活跃

语言占比

Rust
Shell

Release

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

fn my_function() {
    puffin::profile_function!();
    ...
    if ... {
        puffin::profile_scope!("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 50-200 ns.

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 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_egui

Remote profiling

You can use puffin_http to send profile events over TCP to puffin_viewer. This is as easy as:

fn main() {
    let server_addr = format!("127.0.0.1:{}", puffin_http::DEFAULT_PORT);
    let _puffin_server = puffin_http::Server::new(&server_addr).unwrap();
    eprintln!("Run this to view profiling data:  puffin_viewer {server_addr}");
    puffin::set_scopes_on(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.

评论

暂无评论