Files
writing-agent/tools/st-request-diff/ab-stats.mjs
T
chenmoranzhi 1a5ef3b2bc 抓包对比工具补一批一次性脚本:拆预设、对请求、跑 A/B 与拒答抽样。
这些脚本都是我对着酒馆真实请求手工核对用的,留在仓库里方便下次重跑;跑出来的本地数据目录含接口 key,已经写进忽略规则。
2026-10-26 01:09:56 +08:00

14 lines
871 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { readFileSync } from "node:fs";
const lines = readFileSync(process.argv[2], "utf8").trim().split("\n").filter(Boolean);
lines.forEach((l, i) => {
const r = JSON.parse(l);
console.log(
"#" + (i + 1) + " " + r.at + " model=" + r.model + " prompt=" + r.promptTokens + " completion=" + r.completionTokens + " total=" + r.totalTokens + " cached=" + (r.cachedTokens ?? 0) + " 延迟=" + r.latencyMs + "ms",
);
});
const sum = (arr, k) => arr.reduce((n, r) => n + (r[k] || 0), 0);
const half = Math.floor(lines.length / 2);
const all = lines.map((l) => JSON.parse(l));
console.log("\n前一半(wa-core-v1)prompt=" + sum(all.slice(0, 2), "promptTokens") + " completion=" + sum(all.slice(0, 2), "completionTokens"));
console.log("后一半(kunlun)prompt=" + sum(all.slice(2), "promptTokens") + " completion=" + sum(all.slice(2), "completionTokens"));