Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
set.has vs. array.includes vs array.indexOf (object values)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
includes
3938482.5 Ops/sec
lookup
4312828.5 Ops/sec
indexof
4137985.2 Ops/sec
Script Preparation code:
var a = [ { prop: 'height', }, { prop: 'width', }, { prop: 'maxHedight', }, { prop: 'maxWidth', }, { prop: 'maxHeight', }, { prop: 'minWidth', }, { prop: 'color', }, { prop: 'bg', }, { prop: 'backgroundColor', }, { prop: 'opacity', }, { prop: 'm', }, { prop: 'mt', }, { prop: 'mb', }, { prop: 'mr', }, { prop: 'mr', }, { prop: 'mx', }, { prop: 'my', }, { prop: 'p', }, { prop: 'pt', }, { prop: 'pb', }, { prop: 'pr', }, { prop: 'pl', }, { prop: 'px', }, { prop: 'py', }, { prop: 'border', }, { prop: 'boxShadow', }, { prop: 'flex', }, { prop: 'verticalAlign', }, { prop: 'textAlign', }, { prop: 'overflow', }, { prop: 'display', }, { prop: 'cursor' }, ]; var b = new Set(a) var x = a[Math.floor(a.length / 2)];
Tests:
includes
return a.includes(x)
lookup
return b.has(x)
indexof
return a.indexOf(x) >= 0