regex vs indexOf (v2)

Revision 2 of this benchmark created by Pat Cavit on


Preparation HTML

<script>
  var ipadUserAgent = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10';
  
  var regex = /ipad/i;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Sniffing Via Regex
ipad = regex.test(ipadUserAgent);
ready
Sniffing Via indexOf
ipad = ipadUserAgent.indexOf('iPad') > -1;
ready

Revisions

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

  • Revision 1: published by Weiss I Nicht on
  • Revision 2: published by Pat Cavit on
  • Revision 3: published by Jonas Fischer on
  • Revision 4: published on
  • Revision 5: published on
  • Revision 6: published by vamp on
  • Revision 7: published by Leo Dutra on
  • Revision 8: published by Marco Pfeiffer on