Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.prototype.with() vs Array.prototype.toSpliced() 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
With
3712.3 Ops/sec
ToSpliced
3740.7 Ops/sec
HTML Preparation code:
<div id="memory"> </div>
Tests:
With
const memBefore = window.performance.memory.usedJSHeapSize; const data = new Array(10000).fill(0); const formatter = Intl.NumberFormat('ru-RU'); const newData = data.with(123, "new value using With()"); const memDiff = window.performance.memory.usedJSHeapSize - memBefore; if(memDiff!==0){ console.log('WITH ',formatter.format(memDiff)); }
ToSpliced
const memBefore = window.performance.memory.usedJSHeapSize; const data = new Array(10000).fill(0); const formatter = Intl.NumberFormat('ru-RU'); const newData = data.toSpliced(123, 1, "new value using With()"); const memDiff = window.performance.memory.usedJSHeapSize - memBefore; if(memDiff!==0){ console.log('TSPL ',formatter.format(memDiff)); }
Splice
const memBefore = window.performance.memory.usedJSHeapSize; const data = new Array(10000).fill(0); const formatter = Intl.NumberFormat('ru-RU'); const newData = [...data].splice(123, 1, "new value using With()"); const memDiff = window.performance.memory.usedJSHeapSize - memBefore; if(memDiff!==0){ console.log('SPLI ',formatter.format(memDiff)); }