Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map, filter, reduce, intersection comparison
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/117.0.0.0 Safari/537.36 Edg/117.0.2045.40
Browser:
Chrome 117
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Map, filter, reduce
775279.2 Ops/sec
Intersection, union
750474.2 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Tests:
Map, filter, reduce
const offerGameIds = [ { GameId: '4222'}, { GameId: '4208'}, { GameId: '4165'}, { GameId: '4434'}, { GameId: '4200'}, { GameId: '4182'}, { GameId: '4215'}, { GameId: '4114'}, { GameId: '4219'}, { GameId: '4035'}, { GameId: '4070'}, ]; const cmsGameIds = [4222, 4253, 4215, 4141, 4178, 4182, 4135, 4217, 4200, 4194, 4114, 4193, 4219, 4184, 4216, 4142, 4079, 4070, 4035, 4110]; const infoOfferGameIds = offerGameIds.map(item => +item.GameId); const includedGameIds = infoOfferGameIds.filter(id => cmsGameIds.includes(id)); const combinedGameIds = [...includedGameIds, ...cmsGameIds].reduce( (list, item) => (list.includes(item) ? list : [...list, item]), [] );
Intersection, union
const offerGameIds = [ { GameId: '4222'}, { GameId: '4208'}, { GameId: '4165'}, { GameId: '4434'}, { GameId: '4200'}, { GameId: '4182'}, { GameId: '4215'}, { GameId: '4114'}, { GameId: '4219'}, { GameId: '4035'}, { GameId: '4070'}, ]; const cmsGameIds = [4222, 4253, 4215, 4141, 4178, 4182, 4135, 4217, 4200, 4194, 4114, 4193, 4219, 4184, 4216, 4142, 4079, 4070, 4035, 4110]; const infoOfferGameIds = offerGameIds.map(item => +item.GameId); const intersection = _.intersection(infoOfferGameIds, cmsGameIds); const finalArray = _.union(intersection, _.without(cmsGameIds, ...intersection));