Value size vs. string size for array of objects

Benchmark created on


Setup

const data = [{ data: 'blablabla'}];

Test runner

Ready to run.

Testing in
TestOps/sec
Loop through array and sum length of values
let size = 0;

data.forEach(item => {
  size += item.data.length;
});

return size;
ready
Stringify as JSON and get string length
const size = JSON.stringify(data).length;

return size;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.