Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
findIndex + toSpliced vs map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Browser:
Firefox 152
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
Benchmark engine:
Benchmark.js
map
18.3M/s
findIndex + toSpliced
15.1M/s
View exact numbers
Test name
Executions per second
✓
map
18,332,364 Ops/sec
findIndex + toSpliced
15,149,637 Ops/sec
Script Preparation code:
var items = [{name: 'name1', value: 1},{name: 'name2', value: 1},{name: 'name3', value: 1},{name: 'name4', value: 1}]; var search = 'name4'; var result = [];
Tests:
findIndex + toSpliced
var index = items.findIndex(({name}) => name === search); if (index >= 0) { result = items.toSpliced(index, 1, {...items[index], value: 2}); }
map
result = items.map(item => item.name === search ? {...item, value: 2} : item)