Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0
Chrome 122
Mac OS X 10.15.7
Desktop
9 months ago
Test name Executions per second
Array.includes, 10 000 elements 135377.1 Ops/sec
Array.includes, 1 000 000 elements 1537.1 Ops/sec
Set.has, 10 000 elements 4257500.5 Ops/sec
Set.has, 1 000 000 elements 2307697.0 Ops/sec
Array to Set + Set.has, 10 000 elements 4118.7 Ops/sec
Array to Set + Set.has x 100, 10 000 elements 4023.7 Ops/sec
Array.includes x 100, 10 000 elements 8203.0 Ops/sec
Script Preparation code:
Tests:
  • Array.includes, 10 000 elements

  • Array.includes, 1 000 000 elements

  • Set.has, 10 000 elements

  • Set.has, 1 000 000 elements

  • Array to Set + Set.has, 10 000 elements

  • Array to Set + Set.has x 100, 10 000 elements

  • Array.includes x 100, 10 000 elements