intersect v3c
Date tested:
3 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
a
630.5 Ops/sec
b
11370.2 Ops/sec
c
58629.9 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 < 2000; i++){watched.push({programId:Math.random()});} var ignored = [...watched]; ignored.shuffle(); ignored = ignored.slice(0);//50000, 51000);
Tests:
a
watched.filter(wObj => { return !ignored.some((iObj, ndx) => { return iObj.programId === wObj.programId; }); });
b
watched.filter(wObj => !ignored.some((iObj, ndx) => { if (iObj.programId === wObj.programId) { ignored[ndx].programId = ignored.pop().programId; return true; } return false; }) );
c
var iset = new Set(ignored.flatMap(obj => obj.parentId)); watched.filter(wObj => !iset.has(wObj.parentId));
Open this result on MeasureThat.net