regex vs toLowerCase()

Benchmark created by elgreg 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 = /iphone/i;
var match = testString.match(r);
ready
.toLowerCase() first
var r = /iphone/;
var match = testString.toLowerCase().match(r);
ready

Revisions

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