2 个稳定版本
使用旧的 Rust 2015
1.1.0 | 2022 年 12 月 18 日 |
---|---|
1.0.1 | 2019 年 1 月 26 日 |
#139 在 性能分析
2,222 每月下载量
在 josh 中使用
18KB
345 行
将跟踪转换为 Chrome 的 跟踪事件格式
示例
Cargo.toml
rs_tracing = { version = "1.0", features = ["rs_tracing"] }
main.rs
fn main() {
open_trace_file!(".").unwrap();
{
trace_scoped!("complete","custom data":"main");
trace_expr!("trace_expr", println!("trace_expr"));
trace_begin!("duration");
println!("trace_duration");
trace_end!("duration");
}
close_trace_file!();
}
也可以向所有宏添加自定义数据,格式类似于 serde_json::json! 宏,例如。
trace_scoped!("complete","custom":230,"more":"data");
lib.rs
:
rs_tracing 是一个 crate,可以将跟踪事件输出到以 跟踪事件格式 的文件中。
该格式由 chrome://tracing 使用,输出也可以使用 trace2html 转换为 html。
如果 toml 文件中没有设置 rs_tracing 功能,则宏将扩展为空,但 trace_expr 仍将执行表达式,此外,还将删除 rs_tracing 的所有 crate 依赖项。
依赖项
~0–265KB