HTML Preparation code:
Script Preparation code:
Tests:
  • $.hasClass

  • RegExp

  • Dry RegExp

  • indexOf

  • classList

  • hasClassString

  • RegExp 2

  • RegExp 3

  • RegExp 4

  • RegExp 5

  • indexOf simplest

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    $.hasClass
    RegExp
    Dry RegExp
    indexOf
    classList
    hasClassString
    RegExp 2
    RegExp 3
    RegExp 4
    RegExp 5
    indexOf simplest

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
Chrome 87 on Windows
View result in a separate tab
Test name Executions per second
$.hasClass 506538.8 Ops/sec
RegExp 723947.7 Ops/sec
Dry RegExp 348754.1 Ops/sec
indexOf 1679394.6 Ops/sec
classList 1998981.9 Ops/sec
hasClassString 1002785.7 Ops/sec
RegExp 2 1199511.9 Ops/sec
RegExp 3 871022.4 Ops/sec
RegExp 4 1015889.2 Ops/sec
RegExp 5 1092445.0 Ops/sec
indexOf simplest 3336766.8 Ops/sec