Custom url parser

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function getQueryVariable(url, parameter) {
      var query = url.substring(1);
      var vars = query.split("&");
      for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == parameter) {
          return pair[1];
        }
      }
      return null;
    }
   
    function getURLParameter(url, parameter) {
      return (RegExp(parameter + '=' + '(.+?)(&|$)').exec(url) || [, null])[1];
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
getQueryVariable
  getQueryVariable('http://localhost/Banner/BannerClickTest.aspx?re=http://adfarm.mediaplex.com/ad/ck/16688-161755-49566-15?mpt=1384767378989', 're');
pending…
getURLParameter
  getURLParameter('http://localhost/Banner/BannerClickTest.aspx?re=http://adfarm.mediaplex.com/ad/ck/16688-161755-49566-15?mpt=1384767378989', 're');
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment