Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set difference comparison
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/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Windows
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
Symmetrical set difference
250311.9 Ops/sec
Set difference using filter
260890.8 Ops/sec
Array loop
274208.7 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ const arrayA = ["A","B","C","D","E","F","G","H","I","J","K"]; const arrayB = ["C","F","J"];
Tests:
Symmetrical set difference
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ const setA = new Set(arrayA); const setB = new Set(arrayB); // Elements in A not in B const diffA = Array.from(setA).filter(x => !setB.has(x)); // Elements in B not in A const diffB = Array.from(setB).filter(x => !setA.has(x)); const symmetricDifference = [...diffA, ...diffB]; console.log(symmetricDifference);
Set difference using filter
const setA = new Set(arrayA); const setB = new Set(arrayB); // Elements in A not in B const diffA = Array.from(setA).filter(x => !setB.has(x)); console.log(diffA);
Array loop
// Elements in array1 not in array2 const difference1 = arrayA.filter(x => !arrayB.includes(x)); console.log(difference1);