From 4c5ce90e660890dce2cd31a6b70694a7958b3ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=89=E5=90=89=E5=96=B5?= Date: Sun, 22 Mar 2026 23:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=86=E6=9E=90=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=98=88=E5=80=BC=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=20(#3026)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repo/js/背包材料统计/lib/pathProcessor.js | 36 ++++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/repo/js/背包材料统计/lib/pathProcessor.js b/repo/js/背包材料统计/lib/pathProcessor.js index 78d003e21..ed16d3262 100644 --- a/repo/js/背包材料统计/lib/pathProcessor.js +++ b/repo/js/背包材料统计/lib/pathProcessor.js @@ -606,7 +606,10 @@ async function processAllPaths(allPaths, CDCategories, materialCategoryMap, time perTimeSum: 0, perTimeCount: 0, qualifiedPerTimeSum: 0, - estimatedTimeSum: 0 + estimatedTimeSum: 0, + thresholdPerTimeSum: 0, + thresholdPerTimeCount: 0, + thresholdPerTimeList: [] }; } @@ -615,11 +618,9 @@ async function processAllPaths(allPaths, CDCategories, materialCategoryMap, time if (!canRunCD) { failedCD++; - } - if (!(pathCheckResult === true || pathCheckResult.valid)) { + } else if (!(pathCheckResult === true || pathCheckResult.valid)) { failedFrequency++; - } - if (perTime === null) { + } else if (perTime === null) { insufficientRecords++; } else if (isTimeCostOk) { passedTimeCost++; @@ -627,6 +628,14 @@ async function processAllPaths(allPaths, CDCategories, materialCategoryMap, time failedTimeCost++; } + const isNotZeroExceeded = pathCheckResult === true || pathCheckResult.valid; + + if (isNotZeroExceeded && perTime !== null) { + resourceAnalysis[resourceKey].thresholdPerTimeSum += perTime; + resourceAnalysis[resourceKey].thresholdPerTimeCount++; + resourceAnalysis[resourceKey].thresholdPerTimeList.push(perTime); + } + if (canRunCD && (pathCheckResult === true || pathCheckResult.valid) && isTimeCostOk) { resourceAnalysis[resourceKey].qualified++; totalQualifiedPaths++; @@ -659,11 +668,16 @@ async function processAllPaths(allPaths, CDCategories, materialCategoryMap, time log.info(`${CONSTANTS.LOG_MODULES.PATH}\n各材料平均时间成本及达标情况:`); for (const [resourceKey, data] of Object.entries(resourceAnalysis)) { - const avgPerTime = data.perTimeCount > 0 ? (data.perTimeSum / data.perTimeCount).toFixed(4) : '无记录'; - const qualifiedRatio = data.total > 0 ? ((data.qualified / data.total) * 100).toFixed(1) : '0.0'; + const avgThresholdPerTime = data.thresholdPerTimeCount > 0 ? (data.thresholdPerTimeSum / data.thresholdPerTimeCount).toFixed(4) : '无记录'; + const sortedThresholdTimes = [...data.thresholdPerTimeList].sort((a, b) => a - b); + const thresholdIndex = Math.ceil((timeCost / 100) * sortedThresholdTimes.length); + const thresholdPercentileTimes = sortedThresholdTimes.slice(0, thresholdIndex); + const avgThresholdPercentile = thresholdPercentileTimes.length > 0 + ? (thresholdPercentileTimes.reduce((sum, t) => sum + t, 0) / thresholdPercentileTimes.length).toFixed(4) + : '无达标'; + const qualifiedRatio = data.thresholdPerTimeCount > 0 ? ((data.qualified / data.thresholdPerTimeCount) * 100).toFixed(1) : '0.0'; const totalEstimatedTime = formatTime(data.estimatedTimeSum); const avgQualifiedPerTime = data.qualified > 0 ? (data.qualifiedPerTimeSum / data.qualified).toFixed(4) : '无达标'; - const thresholdValue = timeCostStats[resourceKey] ? (timeCostStats[resourceKey].percentiles[timeCost] || timeCostStats[resourceKey].median).toFixed(4) : '无数据'; const isFood = resourceKey && isFoodResource(resourceKey); const isMonster = monsterToMaterials.hasOwnProperty(resourceKey); @@ -677,9 +691,9 @@ async function processAllPaths(allPaths, CDCategories, materialCategoryMap, time log.info(`${CONSTANTS.LOG_MODULES.PATH} --------------------------------------`); log.info(`${CONSTANTS.LOG_MODULES.PATH} ${resourceKey}:`); log.info(`${CONSTANTS.LOG_MODULES.PATH} 达标平均:${avgQualifiedPerTime}${unit}`); - log.info(`${CONSTANTS.LOG_MODULES.PATH} 设置的${timeCost}%分位阈值:${thresholdValue}${unit}`); - log.info(`${CONSTANTS.LOG_MODULES.PATH} 所有有记录路径的平均:${avgPerTime}${unit}`); - log.info(`${CONSTANTS.LOG_MODULES.PATH} 达标:${qualifiedRatio}% (${data.qualified}/${data.total}),总耗时:${totalEstimatedTime}`); + log.info(`${CONSTANTS.LOG_MODULES.PATH} 所有记录平均(排除0记录超限):${avgThresholdPerTime}${unit}`); + log.info(`${CONSTANTS.LOG_MODULES.PATH} 设置的${timeCost}%分位阈值:${avgThresholdPercentile}${unit}`); + log.info(`${CONSTANTS.LOG_MODULES.PATH} 达标:${qualifiedRatio}% (${data.qualified}/${data.thresholdPerTimeCount}),总耗时:${totalEstimatedTime}`); } log.info(`${CONSTANTS.LOG_MODULES.PATH}=============================\n`);