Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
sgdfgdgd
sdfgdfg
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
number
412.2 Ops/sec
string
381.2 Ops/sec
Script Preparation code:
function intersect(arrays) { const response = arrays.length === 1 ? [...arrays[0]] : []; if (arrays.length > 1) { const nOthers = arrays.length - 1; let nShortest = arrays[0].length; let shortest = 0; for (let i = 0; i <= nOthers; i++) { const n = arrays[i].length; if (n < nShortest) { shortest = i; nShortest = n; } } let len; const obj = {}; for (let i = 0; i <= nOthers; i++) { const n = i === shortest ? 0 : i || shortest; //Read the shortest array first. Read the first array instead of the shortest len = arrays[n].length; for (let j = 0; j < len; j++) { const item = arrays[n][j]; if (obj[item] === i - 1) { if (i === nOthers) { response[response.length] = item; obj[item] = 0; } else { obj[item] = i; } } else if (i === 0) { obj[item] = 0; } } } } return response; } n1 = [24005, 18321, 478, 1113369]; n2 = []; s1 = n1.map(i => `${i}`); s2 = []; for (let i = 0; i < 100000; i++) { n2.push(i); s2.push(`${i}`); }
Tests:
number
intersect([n1, n2])
string
intersect([s1, s2])