Array truncate length vs splice

Benchmark created on


Setup

const arr = Array.from({length: 4000}, () => Math.floor(Math.random() * 4000));

Test runner

Ready to run.

Testing in
TestOps/sec
length
arr.length = 40;
ready
splice
arr.splice(-40, 40);
ready

Revisions

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