5 个版本
0.3.1 | 2023 年 8 月 28 日 |
---|---|
0.3.0 | 2023 年 2 月 28 日 |
0.2.0 |
|
0.1.3 | 2021 年 9 月 1 日 |
0.1.1 | 2021 年 3 月 5 日 |
#47 in 性能分析
3,659 每月下载量
73KB
917 代码行
Time-graph
此 crate 提供了一种简单的方法来提取给定函数(或函数内的跨度)被调用的次数、每个函数/跨度的耗时以及记录函数/跨度之间的完整“调用图”。缩进的用例是从软件的实际运行中提取简单的性能数据。重要的是,此 crate 不单独考虑相同函数/跨度的不同调用,而是将所有函数/跨度的调用分组在一起。
此 crate 可以以多种格式输出计时信息,包括 graphviz 的 dot、JSON 数据和美观的 UTF8 表格。以下是使用以下命令运行示例的输出:cargo run --release --example calculation --all-features
(见相应的 代码)
Graphviz 的 dot:
终端表格:
╔════╦══════════════════════════════════════════════╦════════════╦═══════════╦══════════╦═════════╗
║ id ║ span name ║ call count ║ called by ║ total ║ mean ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬═════════╣
║ 0 ║ calculation::run_other_5ms ║ 1 ║ — ║ 6.29ms ║ 6.29ms ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬═════════╣
║ 2 ║ calculation::run_computation ║ 1 ║ — ║ 1.65ms ║ 1.65ms ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬═════════╣
║ 1 ║ calculation::compute ║ 10 ║ 2 ║ 440.19µs ║ 44.02µs ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬═════════╣
║ 4 ║ calculation::{another span} ║ 1 ║ 2 ║ 11.07µs ║ 11.07µs ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬═════════╣
║ 3 ║ calculation::details::bottom_5us ║ 146 ║ 2, 4, 1 ║ 1.62ms ║ 11.10µs ║
╚════╩══════════════════════════════════════════════╩════════════╩═══════════╩══════════╩═════════╝
JSON:
{
"timings": {
"calculation::run_other_5ms": {
"id": 0,
"elapsed": "6.289708ms",
"called": 1
},
"calculation::compute": {
"id": 1,
"elapsed": "440.188µs",
"called": 10
},
"calculation::run_computation": {
"id": 2,
"elapsed": "1.647644ms",
"called": 1
},
"calculation::details::bottom_5us": {
"id": 3,
"elapsed": "1.621202ms",
"called": 146
},
"calculation::{another span}": {
"id": 4,
"elapsed": "11.074µs",
"called": 1
}
},
"calls": [
{ "caller": 1, "callee": 1, "count": 10 },
{ "caller": 3, "callee": 3, "count": 45 },
{ "caller": 3, "callee": 3, "count": 1 },
{ "caller": 4, "callee": 4, "count": 1 },
{ "caller": 3, "callee": 3, "count": 100 }
]
}
许可证和贡献
此 crate 在 MIT 许可证 和 Apache 2.0 许可证 下分发。通过为此 crate 贡献,您同意在相同的许可证下分发您的贡献。
依赖项
~4–6MB
~105K SLoC