Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array difference
(version: 0)
Comparing performance of:
set filter vs array filter
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var o = [ { "text": "vaccine", "value": 30 }, { "text": "infusion", "value": 27 }, { "text": "month", "value": 23 }, { "text": "covid", "value": 19 }, { "text": "neuro", "value": 18 }, { "text": "neurologist", "value": 13 }, { "text": "effect", "value": 13 }, { "text": "receive", "value": 13 }, { "text": "relapse", "value": 12 }, { "text": "week", "value": 12 }, { "text": "drug", "value": 10 }, { "text": "med", "value": 9 }, { "text": "switch", "value": 9 }, { "text": "year", "value": 8 }, { "text": "insurance", "value": 8 }, { "text": "symptom", "value": 7 }, { "text": "feel", "value": 6 }, { "text": "lesion", "value": 6 }, { "text": "dose", "value": 6 }, { "text": "infuse", "value": 6 }, { "text": "diagnosis", "value": 6 }, { "text": "pml", "value": 5 }, { "text": "side", "value": 5 }, { "text": "last", "value": 5 }, { "text": "day", "value": 5 }, { "text": "specialist", "value": 5 }, { "text": "shingle", "value": 5 }, { "text": "mine", "value": 4 }, { "text": "brain", "value": 4 }, { "text": "treatment", "value": 4 }, { "text": "couple", "value": 4 }, { "text": "start", "value": 4 }, { "text": "far", "value": 4 }, { "text": "rituxan", "value": 4 }, { "text": "shoot", "value": 4 }, { "text": "well", "value": 4 }, { "text": "experience", "value": 4 }, { "text": "risk", "value": 4 }, { "text": "thank", "value": 4 }, { "text": "test", "value": 4 }, { "text": "much", "value": 4 }, { "text": "patient", "value": 4 }, { "text": "bad", "value": 4 }, { "text": "time", "value": 3 }, { "text": "stop", "value": 3 }, { "text": "find", "value": 3 }, { "text": "google", "value": 3 }, { "text": "sleep", "value": 3 }, { "text": "choose", "value": 3 }, { "text": "injection", "value": 3 }, { "text": "fine", "value": 3 }, { "text": "optic", "value": 3 }, { "text": "offer", "value": 3 }, { "text": "efficacy", "value": 3 }, { "text": "therapy", "value": 3 }, { "text": "low", "value": 3 }, { "text": "pay", "value": 3 }, { "text": "hair", "value": 3 }, { "text": "medicine", "value": 3 }, { "text": "vaccination", "value": 3 }, { "text": "hour", "value": 3 }, { "text": "wait", "value": 3 }, { "text": "schedule", "value": 3 }, { "text": "happen", "value": 3 }, { "text": "suck", "value": 3 }, { "text": "hospital", "value": 3 }, { "text": "get", "value": 3 }, { "text": "steroid", "value": 3 }, { "text": "cold", "value": 3 }, { "text": "take", "value": 3 }, { "text": "depleter", "value": 2 }, { "text": "antibody", "value": 2 }, { "text": "medication", "value": 2 }, { "text": "neuritis", "value": 2 }, { "text": "back", "value": 2 }, { "text": "rate", "value": 2 }, { "text": "small", "value": 2 }, { "text": "fatigue", "value": 2 }, { "text": "shot", "value": 2 }, { "text": "hate", "value": 2 }, { "text": "single", "value": 2 }, { "text": "kidney", "value": 2 }, { "text": "trust", "value": 2 }, { "text": "lymphocyte", "value": 2 }, { "text": "change", "value": 2 }, { "text": "stay", "value": 2 }, { "text": "cell", "value": 2 }, { "text": "luck", "value": 2 }, { "text": "sort", "value": 2 }, { "text": "prescribe", "value": 2 }, { "text": "high", "value": 2 }, { "text": "recover", "value": 2 }, { "text": "turn", "value": 2 }, { "text": "tec", "value": 2 }, { "text": "flush", "value": 2 }, { "text": "allergic", "value": 2 }, { "text": "pill", "value": 2 }, { "text": "ask", "value": 2 }, { "text": "medicare", "value": 2 }, { "text": "call", "value": 2 } ] var e = [ { "text": "infusion", "value": 27, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 56, "padding": 1, "width": 288, "height": 112, "xoff": 288, "yoff": 0, "x1": 144, "y1": 55, "x0": -144, "y0": -45, "hasText": true, "x": 55, "y": -84 }, { "text": "vaccine", "value": 30, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "x": -119, "y": 11, "width": 288, "height": 120, "xoff": 0, "yoff": 0, "x1": 144, "y1": 59, "x0": -144, "y0": -46, "hasText": true }, { "text": "covid", "value": 19, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 53, "padding": 1, "width": 192, "height": 106, "xoff": 256, "yoff": 0, "x1": 96, "y1": 52, "x0": -96, "y0": -42, "hasText": true, "x": -59, "y": -32 }, { "text": "effect", "value": 13, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 42, "padding": 1, "width": 160, "height": 84, "xoff": 704, "yoff": 0, "x1": 80, "y1": 41, "x0": -80, "y0": -34, "hasText": true, "x": -19, "y": 10 }, { "text": "month", "value": 23, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "x": 66, "y": 39, "width": 256, "height": 120, "xoff": 0, "yoff": 0, "x1": 128, "y1": 59, "x0": -128, "y0": -47, "hasText": true }, { "text": "switch", "value": 9, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 38, "padding": 1, "width": 160, "height": 76, "xoff": 1408, "yoff": 0, "x1": 80, "y1": 37, "x0": -80, "y0": -31, "hasText": true, "x": -67, "y": 11 }, { "text": "symptom", "value": 7, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 31, "padding": 1, "width": 192, "height": 62, "xoff": 1728, "yoff": 0, "x1": 96, "y1": 30, "x0": -96, "y0": -22, "hasText": true, "x": 83, "y": -9 }, { "text": "drug", "value": 10, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 40, "padding": 1, "width": 128, "height": 80, "xoff": 1152, "yoff": 0, "x1": 64, "y1": 39, "x0": -64, "y0": -32, "hasText": true, "x": 1, "y": 38 }, { "text": "neurologist", "value": 13, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 48, "padding": 1, "width": 320, "height": 96, "xoff": 224, "yoff": 0, "x1": 160, "y1": 47, "x0": -160, "y0": -38, "hasText": true, "x": 59, "y": 17 }, { "text": "year", "value": 8, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 35, "padding": 1, "width": 128, "height": 70, "xoff": 960, "yoff": 0, "x1": 64, "y1": 34, "x0": -64, "y0": -21, "hasText": true, "x": -19, "y": 6 }, { "text": "last", "value": 5, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 24, "padding": 1, "width": 64, "height": 48, "xoff": 1920, "yoff": 0, "x1": 32, "y1": 23, "x0": -32, "y0": -20, "hasText": true, "x": -16, "y": 18 }, { "text": "pml", "value": 5, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 24, "padding": 1, "width": 64, "height": 48, "xoff": 1760, "yoff": 0, "x1": 32, "y1": 23, "x0": -32, "y0": -20, "hasText": true, "x": -33, "y": 4 }, { "text": "side", "value": 5, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 24, "padding": 1, "width": 96, "height": 48, "xoff": 1760, "yoff": 0, "x1": 48, "y1": 23, "x0": -48, "y0": -20, "hasText": true, "x": -13, "y": 23 }, { "text": "brain", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 20, "padding": 1, "width": 96, "height": 40, "xoff": 224, "yoff": 120, "x1": 48, "y1": 19, "x0": -48, "y0": -17, "hasText": true, "x": -32, "y": 9 }, { "text": "rate", "value": 2, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 10, "padding": 1, "width": 32, "height": 20, "xoff": 1760, "yoff": 160, "x1": 16, "y1": 9, "x0": -16, "y0": -9, "hasText": true, "x": -31, "y": 9 }, { "text": "specialist", "value": 5, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 24, "padding": 1, "width": 160, "height": 48, "xoff": 1824, "yoff": 0, "x1": 80, "y1": 23, "x0": -80, "y0": -20, "hasText": true, "x": -29, "y": 19 }, { "text": "insurance", "value": 8, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 35, "padding": 1, "width": 192, "height": 70, "xoff": 960, "yoff": 0, "x1": 96, "y1": 34, "x0": -96, "y0": -28, "hasText": true, "x": -119, "y": 11 }, { "text": "week", "value": 12, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 46, "padding": 1, "width": 160, "height": 92, "xoff": 672, "yoff": 0, "x1": 80, "y1": 45, "x0": -80, "y0": -37, "hasText": true, "x": -5, "y": 48 }, { "text": "receive", "value": 13, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 48, "padding": 1, "width": 224, "height": 96, "xoff": 224, "yoff": 0, "x1": 112, "y1": 47, "x0": -112, "y0": -38, "hasText": true, "x": 123, "y": 5 }, { "text": "neuro", "value": 18, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "x": 74, "y": 1, "width": 224, "height": 120, "xoff": 0, "yoff": 0, "x1": 112, "y1": 59, "x0": -112, "y0": -34, "hasText": true }, { "text": "relapse", "value": 12, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "x": 54, "y": 33, "width": 256, "height": 120, "xoff": 0, "yoff": 0, "x1": 128, "y1": 59, "x0": -128, "y0": -47, "hasText": true }, { "text": "lesion", "value": 6, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 42, "padding": 1, "width": 160, "height": 84, "xoff": 320, "yoff": 0, "x1": 80, "y1": 41, "x0": -80, "y0": -34, "hasText": true, "x": 75, "y": -15 }, { "text": "med", "value": 9, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "x": 90, "y": 63, "width": 192, "height": 120, "xoff": 0, "yoff": 0, "x1": 96, "y1": 59, "x0": -96, "y0": -47, "hasText": true }, { "text": "dose", "value": 6, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 54, "padding": 1, "width": 192, "height": 108, "xoff": 160, "yoff": 0, "x1": 96, "y1": 53, "x0": -96, "y0": -43, "hasText": true, "x": 47, "y": -2 }, { "text": "diagnosis", "value": 6, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 57, "padding": 1, "width": 320, "height": 114, "xoff": 384, "yoff": 0, "x1": 160, "y1": 56, "x0": -160, "y0": -45, "hasText": true, "x": -133, "y": 73 }, { "text": "rituxan", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 36, "padding": 1, "width": 160, "height": 72, "xoff": 1472, "yoff": 0, "x1": 80, "y1": 35, "x0": -80, "y0": -29, "hasText": true, "x": -23, "y": -1 }, { "text": "infuse", "value": 6, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "width": 224, "height": 120, "xoff": 160, "yoff": 0, "x1": 112, "y1": 59, "x0": -112, "y0": -48, "hasText": true, "x": 4, "y": 41 }, { "text": "patient", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 38, "padding": 1, "width": 160, "height": 76, "xoff": 448, "yoff": 120, "x1": 80, "y1": 37, "x0": -80, "y0": -30, "hasText": true, "x": -132, "y": 28 }, { "text": "feel", "value": 6, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 60, "padding": 1, "x": -133, "y": -20, "width": 160, "height": 120, "xoff": 0, "yoff": 0, "x1": 80, "y1": 59, "x0": -80, "y0": -48, "hasText": true }, { "text": "shingle", "value": 5, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 57, "padding": 1, "width": 256, "height": 114, "xoff": 160, "yoff": 0, "x1": 128, "y1": 56, "x0": -128, "y0": -45, "hasText": true, "x": -82, "y": 42 }, { "text": "day", "value": 5, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 57, "padding": 1, "x": -69, "y": 11, "width": 160, "height": 114, "xoff": 0, "yoff": 0, "x1": 80, "y1": 56, "x0": -80, "y0": -45, "hasText": true }, { "text": "far", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 46, "padding": 1, "width": 128, "height": 92, "xoff": 768, "yoff": 0, "x1": 64, "y1": 45, "x0": -64, "y0": -37, "hasText": true, "x": 50, "y": 5 }, { "text": "treatment", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 44, "padding": 1, "width": 256, "height": 88, "xoff": 160, "yoff": 0, "x1": 128, "y1": 43, "x0": -128, "y0": -31, "hasText": true, "x": -48, "y": 14 }, { "text": "couple", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 48, "padding": 1, "width": 192, "height": 96, "xoff": 160, "yoff": 0, "x1": 96, "y1": 47, "x0": -96, "y0": -38, "hasText": true, "x": -140, "y": 14 }, { "text": "experience", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 48, "padding": 1, "width": 288, "height": 96, "xoff": 672, "yoff": 0, "x1": 144, "y1": 47, "x0": -144, "y0": -38, "hasText": true, "x": -36, "y": 43 }, { "text": "mine", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 51, "padding": 1, "x": -90, "y": -35, "width": 192, "height": 102, "xoff": 0, "yoff": 0, "x1": 96, "y1": 50, "x0": -96, "y0": -40, "hasText": true }, { "text": "google", "value": 3, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 31, "padding": 1, "width": 128, "height": 62, "xoff": 1664, "yoff": 0, "x1": 64, "y1": 30, "x0": -64, "y0": -25, "hasText": true, "x": -40, "y": 29 }, { "text": "test", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 51, "padding": 1, "width": 160, "height": 102, "xoff": 864, "yoff": 0, "x1": 80, "y1": 50, "x0": -80, "y0": -36, "hasText": true, "x": -12, "y": 17 }, { "text": "much", "value": 4, "font": "Roboto", "style": "normal", "weight": "bold", "rotate": 0, "size": 51, "padding": 1, "width": 192, "height": 102, "xoff": 864, "yoff": 0, "x1": 96, "y1": 50, "x0": -96, "y0": -40, "hasText": true, "x": 67, "y": -18 } ]
Tests:
set filter
const result = []; const parsedExcluded = new Set(e.map(x => x.text)); for (let word of o) { if (parsedExcluded.has(word.text)) { parsedExcluded.delete(word.text); } else { result.push(word); } }
array filter
const result = o.filter(x => !e.some(y => y.text === x.text))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
set filter
array filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It appears that we are provided with a JSON object containing an array of text objects, as well as two benchmark definitions for filtering out text that is already present in another set. The first benchmark definition uses the `Set` data structure to filter out duplicate text and creates a new array with the remaining words. The second benchmark definition uses the `filter()` method to achieve the same result. We are also provided with the results of these benchmarks, which include metrics such as the browser used, device platform, operating system, executions per second, and test name. Given this information, it seems that we are tasked with comparing the performance of two different approaches for filtering out duplicate text: using a `Set` data structure versus using the `filter()` method. Here is my analysis: * The `set filter` benchmark definition is likely to be faster than the `array filter` benchmark definition because accessing and manipulating elements in an array can be slower than working with a `Set`. * However, the actual performance difference between these two approaches depends on various factors such as the size of the input data, the language being used to implement the filters, and the specific requirements of the application. Based on this analysis, here is my answer: The `set filter` benchmark definition will likely perform better than the `array filter` benchmark definition. However, without more information about the specific use case or requirements of the application, it's difficult to provide a definitive answer.
Related benchmarks:
Loop perf
lodash_array_objects
array some vs _.some III
Destructure array vs Array index
Filter and return property values of an array of objects
Comments
Confirm delete:
Do you really want to delete benchmark?