Set the decision and its input
Both synthetic arrays contain100 generated rows. Short rows have one f0 field with X; long rows have fifty f0..f49 fields plus a twenty-character attachment label. Their UTF-8 JSON sizes are1,101 and52,801 bytes. Equal row counts do not make these supplied payloads equal loads.
| Case | Input JSON |
|---|---|
| Base test | {"rows":100} |
Run the supplied comparison
The programme actually serializes the expanded rows and measures Buffer byte length. The attachment is inline synthetic text; the result is not compressed network traffic, a binary file size or a real throughput benchmark.
| Path | Output JSON |
|---|---|
| Faulty path | {"shortBytes":1101,"longBytes":52801,"equalLoad":true} |
| Required path | {"shortBytes":1101,"longBytes":52801,"equalLoad":false} |
import assert from 'node:assert/strict';
const smallWhole=(x,max)=>Number.isSafeInteger(x)&&x>=0&&x<=max;
const run=function run(i,corrected=true){
if(!smallWhole(i.rows,100))return {held:true};
const generate=(fields,attachment)=>Array.from({length:i.rows},()=>({...Object.fromEntries(Array.from({length:fields},(_,n)=>['f'+n,'X'])),...(attachment?{attachment:'X'.repeat(attachment)}:{})}));
const short=generate(1,0),long=generate(50,20),bytes=x=>Buffer.byteLength(JSON.stringify(x));
return {shortBytes:bytes(short),longBytes:bytes(long),equalLoad:corrected?bytes(short)===bytes(long):short.length===long.length};
};
const cases=[{"input":{"rows":100},"corrected":false,"expected":{"shortBytes":1101,"longBytes":52801,"equalLoad":true}},{"input":{"rows":100},"corrected":true,"expected":{"shortBytes":1101,"longBytes":52801,"equalLoad":false}},{"input":{"rows":1},"corrected":true,"expected":{"shortBytes":12,"longBytes":529,"equalLoad":false}},{"input":{"rows":0},"corrected":true,"expected":{"shortBytes":2,"longBytes":2,"equalLoad":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
One row gives12 versus529 bytes including array brackets. Empty arrays both contain two bytes and are equal for this serialized shape.
- Define complete payload shapes
- Serialize both supplied arrays
- Compare measured bytes and rows
Do not infer production bandwidth or latency from this byte comparison.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| one populated row | {"rows":1} | {"shortBytes":12,"longBytes":529,"equalLoad":false} |
| empty arrays | {"rows":0} | {"shortBytes":2,"longBytes":2,"equalLoad":true} |
Can the base datasets be called equivalent from100 rows each?
Show the worked answer
No. Their measured serialized sizes differ by51,700 bytes. Retain field and attachment shape beside row count.