Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS array test
(version: 0)
Test splice vs assign
Comparing performance of:
Splice vs Assign array
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var input = []; var new_array = []; for (var i = 0; i < 500; i++) { input.push({ id: i, data: Math.random() .toString(36) .replace(/[^a-z]+/g, "") .substr(0, 10), title: Math.random() .toString(36) .replace(/[^a-z]+/g, "") .substr(0, 10), is_active: Math.random() > 0.5 ? true : false, }); new_array.push({ id: i, data: Math.random() .toString(36) .replace(/[^a-z]+/g, "") .substr(0, 10), title: Math.random() .toString(36) .replace(/[^a-z]+/g, "") .substr(0, 10), is_active: Math.random() > 0.5 ? true : false, }); }
Tests:
Splice
input.splice(0, input.length, new_array);
Assign array
input = new_array
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Splice
Assign array
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Splice
5069670.5 Ops/sec
Assign array
7312821.5 Ops/sec
Related benchmarks:
Slice, splice, and filter
Array.filter vs. Array.indexOf + splice
Splice vs new Array Modulo
Splice vs new Array Fix
Comments
Confirm delete:
Do you really want to delete benchmark?