pi-ptc-meter 1.0.31 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +0 -37
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -200,46 +200,9 @@ function statsLine(th: number, med: number, rows: Row[]): string {
|
|
|
200
200
|
if (secs !== null) {
|
|
201
201
|
parts.push(`实际 ${secs}s`);
|
|
202
202
|
if (lastTurnHit !== null && lastTurnHit < 90) parts.push(`命中 ${lastTurnHit}%(低)`);
|
|
203
|
-
if (lastTurnEstCalls !== null && lastTurnEstCalls > 0) {
|
|
204
|
-
const dc = Math.round(((last - lastTurnEstCalls) / lastTurnEstCalls) * 100);
|
|
205
|
-
if (Math.abs(dc) <= 10) parts.push(`预计 ${lastTurnEstCalls} / 实际 ${last} 次(基本吻合)`);
|
|
206
|
-
else parts.push(`预计 ${lastTurnEstCalls} 次 / 实际 ${last} 次(偏差 ${dc >= 0 ? "+" : ""}${dc}%)`);
|
|
207
|
-
}
|
|
208
|
-
if (lastTurnEst !== null) {
|
|
209
|
-
const dev = Math.round(((lastTurnMs / 1000 - lastTurnEst) / lastTurnEst) * 100);
|
|
210
|
-
parts.push(`预计 ${lastTurnEst}s / 实际 ${secs}s(偏差 ${dev >= 0 ? "+" : ""}${dev}%)`);
|
|
211
|
-
} else {
|
|
212
|
-
const base = Math.round(median(rows.map((r) => r.ms)) / 1000);
|
|
213
|
-
// 借鉴 think-anchor 的自适应:声明率已高时不再每轮催(实测 88.9% 声明率下这句话是纯噪音)
|
|
214
|
-
const declRate = rows.length ? rows.filter((r) => typeof r.estCalls === "number" && (r.estCalls as number) > 0).length / rows.length : 0;
|
|
215
|
-
const nudge = declRate < 0.6 ? " → 本轮开工前先报「预计 N 次」" : "";
|
|
216
|
-
parts.push((base > 0 ? "预计未声明(同类中位 " + base + "s)" : "预计未声明") + nudge);
|
|
217
|
-
}
|
|
218
203
|
}
|
|
219
204
|
// 校正指引(回路自动纠偏):近若干轮系统性偏离时,直接给出本轮该报的倍数——不靠自觉。
|
|
220
|
-
// 调用数校正:次数由任务类型决定,方差远小于时长——优先用它给指引。
|
|
221
205
|
try {
|
|
222
|
-
const ecRows = rows.filter((r) => typeof r.estCalls === "number" && (r.estCalls as number) > 0);
|
|
223
|
-
if (ecRows.length >= 3) {
|
|
224
|
-
const dcs = ecRows.map((r) => ((r.calls - (r.estCalls as number)) / (r.estCalls as number)) * 100);
|
|
225
|
-
const mdc = median(dcs);
|
|
226
|
-
if (mdc <= -20 || mdc >= 20) {
|
|
227
|
-
const f = Math.min(3, Math.max(0.2, Math.round((1 + mdc / 100) * 100) / 100)); // 夹在 0.2–3:极端中位(声明失真)不放大成荒谬倍数
|
|
228
|
-
const lastEst = ecRows[ecRows.length - 1].estCalls as number;
|
|
229
|
-
parts.push(`近 ${ecRows.length} 轮调用数系统性${mdc < 0 ? "高估" : "低估"}(中位 ${mdc > 0 ? "+" : ""}${Math.round(mdc)}%)→ 本轮按约 ${f} 倍报(≈ ${Math.max(1, Math.round(lastEst * f))} 次)`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
} catch { /* 静默 */ }
|
|
233
|
-
try {
|
|
234
|
-
const estRows = rows.filter((r) => typeof r.est === "number" && (r.est as number) > 0);
|
|
235
|
-
if (estRows.length >= 3) {
|
|
236
|
-
const devs = estRows.map((r) => ((r.ms / 1000) - (r.est as number)) / (r.est as number) * 100);
|
|
237
|
-
const md = median(devs);
|
|
238
|
-
if (md <= -20 || md >= 20) {
|
|
239
|
-
const factor = Math.min(3, Math.max(0.2, Math.round((1 + md / 100) * 100) / 100));
|
|
240
|
-
parts.push(`近 ${estRows.length} 轮耗时系统性${md < 0 ? "高估" : "低估"}(中位 ${md > 0 ? "+" : ""}${Math.round(md)}%)→ 本轮按约 ${factor} 倍报`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
206
|
} catch { /* 指引失败不影响统计行 */ }
|
|
244
207
|
const verdict = last >= th
|
|
245
208
|
? `超阈值 ${th} · 判据 = 本轮计数不超阈值且无同类调用可并(可并性人工复核)`
|