regex vs. string equals (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  var testString = 'http:';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Google version
var g_proto = ('https:' == document.location.protocol ? 'https:' : 'http:');
ready
Agillic version
var a_proto = (/^http:/.test(document.location) ? "http" : "https");
ready
Plain regex
var p_proto = (/^http:/.test(testString));
ready
Plain equals
var pe_proto = (testString == 'http:');
ready

Revisions

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