regex vs toLowerCase() (v2)

Revision 2 of this benchmark created on


Description

perf difference between running a string through .toLowerCase() before applying a regex or just doing it in the regex.

Setup

var testString = "iPhone";

Test runner

Ready to run.

Testing in
TestOps/sec
regex
var r = /ph/i;

var match = ~testString.search(r);
ready
.toLowerCase() first
var r = "PH";
var match = ~testString.toLowerCase().indexOf(r.toLowerCase());
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.