perf_runner API

Luna-Flow/linear-algebra/perf_runner 是一个可执行程序,它运行一个基准用例并打印一条 JSON 记录:要么是诊断校验和,要么是计时样本列表。它没有公开的库项。

源码:src/perf_runner/main.mbt。测量方法见 perf_runner 设计。

公开项

无;该包为 pkgtype(kind: "executable")。

命令行

moon run src/perf_runner --target native <case-id> [--case-file <path>] [--repeat <n>] [--samples <n>] [--warmup <n>]
参数默认值含义
<case-id>必填在 perf_support 中注册的用例 id
--case-file <path>bench/datasets/cases/<case-id>.jsonfixture 文件;缺失时重新生成
--repeat <n>1每个计时样本的调用次数,n>0n > 0
--samples <n>0计时样本数;0 表示诊断模式
--warmup <n>0采样前不计时的预热轮数

参数无效或缺失时,打印用法信息并中止。

输出

诊断模式(--samples 0)将用例运行 repeat 次,并打印 case_diagnostic_payload:{"kind":"diagnostic", ..., "checksum":"<u64>"}。repeat 次运行的校验和是各次校验和的折叠。

采样模式打印 {"kind":"benchmark", ..., "repeat":<n>, "samples":[t1, t2, ...]},其中每个 tit_i 是一个样本经过的挂钟时间除以 repeat,单位为纳秒。

对于 mutation_policy = "scratch_per_sample" 的用例,每次调用前(计时开始前)都会复制输入。