Portable Callgrind records for MoonBit: call sites, target positions and exact counters.
git clone https://github.com/Rindoncreate/mooncallgrind.git
cd mooncallgrind
moon check --target js --deny-warn
moon build --target js --deny-warn
moon test --target js --deny-warn
moon run examples/sites --target js
node bin/mooncallgrind.mjs inspect examples/two-sites.callgrind
node bin/mooncallgrind.mjs totals examples/two-sites.callgrind Ir
node bin/mooncallgrind.mjs normalize examples/two-sites.callgrind normalized.callgrind
node bin/mooncallgrind.mjs diff examples/two-sites.callgrind normalized.callgrind Irlet p = @cg.parse("events: Ir\nfn=main\ncfn=work\ncalls=2 70\n10 30\n")
for record in p.records {
match record.kind {
SelfCost => ()
Call(count, target, positions) =>
println("\{record.positions[0]} -> \{target.function_name}:\{positions[0]}, calls=\{count}")
}
}| 接口 | 行为 |
|---|---|
| parse(text) | 返回 Profile;失败时抛出带行号的 Syntax、Unsupported 或 Resource |
| normalize(text) | 规范化为绝对位置和显式名称 ID,保留支持的记录与头字段 |
| profile.self_totals(event) | 按每段事件名定位列,合并函数自身成本,排除调用边成本 |
| diff(before, after, event) | 返回精确 before/after 值,不推断回归原因 |
pub(all) suberror ParseError {
Syntax(Int, String)
Unsupported(Int, String)
Resource(Int, String)
} derive(Debug)Install
Download zipPortable Callgrind records for MoonBit: call sites, target positions and exact counters.