Skip to content
Astera Technology

Compare payload shape as well as row count

Measure actual serialized bytes for two supplied equal-row workloads.

Download complete case notes and answer keys ↓

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.

Filled local test worksheet
CaseInput JSON
Base test{"rows":100}
Download editable CSV ↓

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.

Faulty and required outputs
PathOutput JSON
Faulty path{"shortBytes":1101,"longBytes":52801,"equalLoad":true}
Required path{"shortBytes":1101,"longBytes":52801,"equalLoad":false}
Download editable CSV ↓
Complete local Node24.14.1 programme
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);}
Download runnable example ↓

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.

  1. Define complete payload shapes
  2. Serialize both supplied arrays
  3. Compare measured bytes and rows

Do not infer production bandwidth or latency from this byte comparison.

Editable boundary inputs and outputs
ConditionInput JSONExpected output JSON
one populated row{"rows":1}{"shortBytes":12,"longBytes":529,"equalLoad":false}
empty arrays{"rows":0}{"shortBytes":2,"longBytes":2,"equalLoad":true}
Download editable CSV ↓

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.

Related resources