Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test Loop Set Data2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
Browser:
Firefox 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
1
6788.7 Ops/sec
2
9708.7 Ops/sec
Script Preparation code:
var arr = new Array(15000); arr.fill({ id: 0, text: "test" }); arr = arr.map((el, idx) => el.id = idx); var foo = Math.floor(Math.random() * 15000);
Tests:
1
const index = arr.findIndex((itm) => itm.id === foo); const newArr = [...arr]; arr[index] = {...arr[index], text: "edittest"}
2
const newArr = arr.map((row, index) => { if (index === 1) { return { ...arr[0], text: "edittest" } } })