tarinai/scripts/non_tarinai_performance_regression_audit.js
2026-07-18 13:06:02 +09:00

21 lines
2.1 KiB
JavaScript

"use strict";
const fs = require("fs");
const viewSrc = fs.readFileSync("js/world_view.js", "utf8");
const maintenanceSrc = fs.readFileSync("js/simulation_maintenance_system.js", "utf8");
const spatialSrc = fs.readFileSync("js/world_spatial_budget.js", "utf8");
const mainSrc = fs.readFileSync("js/main.js", "utf8");
const statsSrc = fs.readFileSync("js/ui_charts.js", "utf8");
const decaySrc = fs.readFileSync("js/item_lifecycle_decay_system.js", "utf8");
function ok(cond, msg) { if (!cond) { console.error(`[FAIL] ${msg}`); process.exitCode = 1; } else console.log(`[OK] ${msg}`); }
ok(!viewSrc.includes('terrain-periodic'), "terrain cache is not globally invalidated on a timer");
ok(viewSrc.includes('return `${worldRef.fieldType || "garden"}:${worldRef.groundType || "soil"}`'), "terrain signature excludes object-count churn");
ok(maintenanceSrc.includes('_nextStructureDependencyCheckAt'), "structure dependency safety sweeps are throttled");
ok(maintenanceSrc.includes('_nextItemCompactAt') && maintenanceSrc.includes('_nextAntCompactAt'), "item and ant compactions are staggered");
ok(!maintenanceSrc.includes('countsInterval = 2.75'), "item bucket rebuilds are no longer forced by a periodic timer");
ok(spatialSrc.includes('if (terrainChanged) this.markTerrainDirty?.("compact-terrain-items")'), "item compaction only invalidates terrain when cached terrain items were removed");
ok(!spatialSrc.includes('else this.markTerrainDirty?.(reason);'), "adding ordinary objects no longer invalidates the whole terrain cache");
ok(mainSrc.includes('requestIdleCallback') && mainSrc.includes('scheduleStatsRefresh'), "periodic stats refresh is deferred outside the simulation frame");
ok(statsSrc.includes('world.tarinaiCounts?.()') && statsSrc.includes('collectDynamicColonyStats'), "stats use differential population counters and isolate dynamic aggregation");
ok(statsSrc.includes('colonyStatsUiVisible') && mainSrc.includes('!colonyStatsUiVisible()'), "hidden colony UI skips scheduled stats work");
ok(decaySrc.includes('"splat-fade"'), "splat fading invalidates only its local terrain chunk");
if (process.exitCode) process.exit(process.exitCode);