Files
44r0n7andClaude Opus 5.5 3ee85429fd Sidewall belt and screen drawing, cheaper cleat checks (t42, t43)
Far sidewall drawn behind the load with cleat ribs at their physics
positions; sloped screens get a tinted mesh between rails and shake only
when loaded. Powder skips cleat checks outside chunks that have cleats,
and empty slopes let their chunks sleep. Record the screw conveyor and
stall/carry-depth decisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 20:08:21 -04:00

52 lines
2.8 KiB
JavaScript

// Many loaded slopes, with a fresh deterministic world for each timing sample.
const { performance } = require('perf_hooks');
const { load, flatWorld } = require(process.env.DG_HARNESS || '../../test/harness');
const { run } = load();
const assert = require('node:assert/strict');
const samples=[];
for(let sample=0;sample<6;sample++) {
flatWorld(run,1024,512,496);
run(`RS=7;money=1e9;AMB.fill(20);temp.fill(20);hot.fill(0);
for(let row=0;row<6;row++)for(let col=0;col<8;col++)for(let k=0;k<12;k++){
const bx=col*30+4+k,by=row*18+35-k;
placeBlock(BP_BELT_UP,1,bx,by,true);
for(let x=bx*4;x<bx*4+4;x++){const y=beltFaceY(BP_BELT_UP,bx,by,x);for(let h=1;h<=4;h++)setCell((y-h)*W+x,SAND,20,0);}
}
for(let k=0;k<60;k++)simTick();`);
const start=performance.now();run('for(let k=0;k<240;k++)simTick();');
if(sample) samples.push((performance.now()-start)/240);
}
assert(samples.length===5 && samples.every(n=>Number.isFinite(n) && n>0));
samples.sort((a,b)=>a-b);
console.log(`576 loaded slope blocks, median ${samples[2].toFixed(3)} ms/tick; samples ${samples.map(v=>v.toFixed(3)).join(', ')}`);
// No slopes: use the zero flag supplied once per chunk by simMove. Older powder ignores it.
flatWorld(run,512,384,376);
run('RS=7;for(let y=32;y<350;y+=2)for(let x=32;x<480;x++){mat[y*W+x]=SAND;mat[(y+1)*W+x]=STONE;}');
const powderSamples=[];
for(let sample=0;sample<6;sample++) {
const start=performance.now();
run('for(let k=0;k<30;k++)for(let y=32;y<350;y+=2)for(let x=32;x<480;x++)powder(y*W+x,x,y,SAND,0);');
if(sample)powderSamples.push(performance.now()-start);
}
assert(powderSamples.length===5 && powderSamples.every(n=>Number.isFinite(n) && n>0));
powderSamples.sort((a,b)=>a-b);
console.log(`2.14M powder calls without cleats, median ${powderSamples[2].toFixed(2)} ms`);
// Generated terrain plus a replenished falling sand curtain, with zero or 50 slope blocks.
for (const slopes of [0, 50]) {
const times = [];
for (let sample = 0; sample < 6; sample++) {
run(`generateWorld(12345, 1024, 640); weather.next=1e15; money=1e9;
for(let y=16;y<160;y++)for(let x=80;x<480;x++)setCell(y*W+x,EMPTY,AMB[y],0);
for(let k=0;k<${slopes};k++) {const bx=25+(k%10),by=32+Math.floor(k/10)*5-(k%10);
placeBlock(BP_BELT_UP,1,bx,by,true);}
for(let t=0;t<60;t++){for(let x=80;x<480;x++)if(mat[16*W+x]===EMPTY)setCell(16*W+x,SAND,AMB[16],0);simTick();}`);
const start = performance.now();
run(`for(let t=0;t<180;t++){for(let x=80;x<480;x++)if(mat[16*W+x]===EMPTY)setCell(16*W+x,SAND,AMB[16],0);simTick();}`);
if (sample) times.push((performance.now()-start)/180);
}
assert(times.every(n=>Number.isFinite(n) && n>0)); times.sort((a,b)=>a-b);
console.log(`generated falling world, ${slopes} slopes: ${times[2].toFixed(3)} ms/tick; ${times.map(n=>n.toFixed(3)).join(', ')}`);
}