Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
set.has vs. array.includes vs array.indexOf (string values) 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser:
Chrome 144
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
includes
3602797.0 Ops/sec
lookup
172813488.0 Ops/sec
indexof
43732880.0 Ops/sec
Script Preparation code:
var a = [ 'height', 'width', 'maxHeight', 'maxWidth', 'maxHeight', 'minWidth', 'color', 'bg', 'backgroundColor', 'opacity', 'm', 'mt', 'mb', 'mr', 'mr', 'mx', 'my', 'p', 'pt', 'pb', 'pr', 'pl', 'px', 'py', 'border', 'boxShadow', 'flex', 'verticalAlign', 'textAlign', 'overflow', 'display', 'cursor' ]; var b = new Set(a)
Tests:
includes
a.includes('mx'); a.includes('pl'); a.includes('display'); a.includes('my'); a.includes('pb'); a.includes('textAlign'); a.includes('textAlign'); a.includes('p'); a.includes('opacity'); a.includes('backgroundColor'); a.includes('ml'); a.includes('bg'); a.includes('pt'); a.includes('mt'); a.includes('flex');
lookup
b.has('mx'); b.has('pl'); b.has('display'); b.has('my'); b.has('pb'); b.has('textAlign'); b.has('textAlign'); b.has('p'); b.has('opacity'); b.has('backgroundColor'); b.has('ml'); b.has('bg'); b.has('pt'); b.has('mt'); b.has('flex');
indexof
return a.indexOf('mx') >= 0