intersect v2c
Date tested:
4 months ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
Test name
Executions per second
some
0.8 Ops/sec
some; pop and swap
191.2 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
Array.prototype.shuffle = function() { let m = this.length, i; while (m) { i = (Math.random() * m--) >>> 0; [this[m], this[i]] = [this[i], this[m]] } return this; }; var watched = []; for(let i = 0; i < 100000; i++){watched.push({programId:Math.random()});} var ignored = [...watched]; ignored.shuffle(); ignored = ignored.slice(50000, 59000);
Tests:
some
watched.filter(wObj => { return !ignored.some((iObj, ndx) => iObj.programId === wObj.programId); });
some; pop and swap
watched.filter(wObj => !ignored.some((iObj, ndx) => { if (iObj.programId === wObj.programId) { ignored[ndx].programId = ignored.pop().programId; return true; } return false; }) );
Open this result on MeasureThat.net