Demo benchmark
From https://benchmarkjs.com/
Date tested:
4 years ago
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1
Test name
Executions per second
RegExp#test
25298770.0 Ops/sec
String#indexOf
23271740.0 Ops/sec
String#match
18022970.0 Ops/sec
Benchmark definition (click to collapse):
HTML Preparation code:
<div>This is demo</div>
Script Preparation code:
console.log("js preparation");
Tests:
RegExp#test
/o/.test('Hello World!');
String#indexOf
'Hello World!'.indexOf('o') > -1;
String#match
!!'Hello World!'.match(/o/);
Open this result on MeasureThat.net