Profiler: real-GPU breakdown by zoom, look and scene, with a baseline (t88 phase 0)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Profiling fixtures start in the same state after previous scenes and warm-up ticks.
|
||||
const fs = require('fs'), path = require('path'), crypto = require('crypto');
|
||||
const { load, suite } = require('./harness');
|
||||
const { run } = load();
|
||||
const { check, done } = suite();
|
||||
// Only the fixture's browser shell is stubbed; all simulation functions are real.
|
||||
run(`const GAME = {}, R = {particles: [], camX: 0, camY: 0}, SET = {};
|
||||
const document = {querySelectorAll: () => []}; let acc;
|
||||
function enterGame() {} function snapCamera() {}`);
|
||||
run(fs.readFileSync(path.join(__dirname, '../tools/perf-scenes.js'), 'utf8'));
|
||||
function fixture(name) {
|
||||
run(`perfScene('${name}', 1024, 640);`);
|
||||
const hash = crypto.createHash('sha256');
|
||||
for (const name of ['mat', 'temp', 'flags', 'part', 'awake', 'hot'])
|
||||
hash.update(run(`Buffer.from(${name}.buffer)`));
|
||||
hash.update(run('JSON.stringify([RS, WS, stats])'));
|
||||
return hash.digest('hex');
|
||||
}
|
||||
const first = fixture('factory');
|
||||
check('factory fixture repeats exactly', fixture('factory') === first);
|
||||
run('for (let k = 0; k < 600; k++) simTick();');
|
||||
check('factory fixture repeats after a warmed simulation', fixture('factory') === first);
|
||||
const moved = run('stats.moved');
|
||||
run('for (let k = 0; k < 240; k++) simTick();');
|
||||
check('factory still transports grains after four seconds', run('stats.moved') > moved + 1000);
|
||||
check('both factory feeds remain active', run('machines.filter(m => m && m.type === "silo" && tick - m.pourT < 10).length') === 2);
|
||||
check('factory has fuel remaining in both silos', run('machines.filter(m => m && m.type === "silo" && m.sn > 0).length') === 2);
|
||||
const heat = fixture('heat');
|
||||
fixture('settled');
|
||||
check('heat fixture repeats after another scene', fixture('heat') === heat);
|
||||
done();
|
||||
Reference in New Issue
Block a user