Demo benchmark
From https://benchmarkjs.com/
Date tested:
7 years ago
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0
Test name
Executions per second
RegExp#test
8707454.0 Ops/sec
String#indexOf
42005060.0 Ops/sec
String#match
4116415.5 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