delete key vs destructure

Benchmark created on


Setup

const items = Array.from(Array(10000).keys())

const BIG_DATA_SET = items.reduce((o, key) => ({ ...o, [`${key}`]: {
  request: {
    id: `${key}`
  }
}}), {})

const target = '5123'
const prevData = {data: BIG_DATA_SET}

console.log(Object.keys(BIG_DATA_SET).length)

Test runner

Ready to run.

Testing in
TestOps/sec
destructure
const { [target]: {}, ...rest } = prevData.data
return { data: rest };
ready
delete
delete prevData.data[target];
return { data: prevData.data };
ready

Revisions

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