prefixsearch

Benchmark created on


Preparation HTML

<script>
  var string = 'http://www.google.com/search?hl=en&source=hp&biw=978&bih=760&q=javascript&aq=f&aqi=g10&aql=&oq=&gs_rfai=';
  var substring = 'http://www.google.com/';
  var subsubstring = 'http:';
  var ptn_substring = /^http:\/\/www\.google\.com\//;
  var ptn_subsubstring = /^http:/;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
RegExp::test
ptn_substring.test(string);
ready
String::indexOf
string.indexOf(substring) === 0;
ready
String::lastIndexOf
string.lastIndexOf(substring, 0) === 0;
ready
RegExp::test (2)
ptn_subsubstring.test(string);
ready
String::indexOf (2)
string.indexOf(subsubstring) === 0;
ready
String::lastIndexOf (2)
string.lastIndexOf(subsubstring, 0) === 0;
ready

Revisions

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