clickDownMultiple

JavaScript performance comparison

Test case created by SenorSmartyPants

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  iEpisodesPerPage = 15;
  iEpisodesLength = 22;
  
   var   clickDownMultiple2 = function() {
  
                  var iPageNew = 1 + Math.floor(iEpisodeId / iEpisodesPerPage);
                  iEpisodeId = (iEpisodeId % iEpisodesLength) + 1;
                  if (iEpisodeId == 1) {
                      //rolled back to page 1
                      iPageNew = 1;
                  }
                  if (iPageNew != iPage) {
                      iPage = iPageNew;
                      //toggletab();
                  } else {
                      //showNfocus();
                  }
              },
  
    clickDownMultiple = function() {
                  iEpisodeId = iEpisodeId + 1;
                  if (iEpisodeId > iEpisodesLength) {
                      //go to first episode
                      iEpisodeId = 1;
                      iPage = 1;
                      //toggletab();
                      return;
                  } else if ((iEpisodeId % iEpisodesPerPage) == 1) {
                      //moved to a new page
                      iPage = iPage + 1;
                      //toggletab();
                      return; 
                  }
                  //just move down
                  //showNfocus();
              },
  
              clickDown = function() {
                  if ((iEpisodeId / (iPage * iEpisodesPerPage)) == 1) {
                          iPage = iPage + 1;
                          iEpisodeId = iEpisodeId + 1;
                  } else {
                      iEpisodeId = iEpisodeId + 1;
                      if (iEpisodeId > iEpisodesLength) {
                          iEpisodeId = 1;
                          iPage = 1;
                      }
                  }
              };

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
clickDownMultiple
iEpisodeId = 1;
iPage = 1;
clickDownMultiple();
pending…
1m2
iEpisodeId = 1;
iPage = 1;
clickDownMultiple2();
pending…
clickDown Original
iEpisodeId = 1;
iPage = 1;
clickDown();
pending…
15m2
iEpisodeId = 15;
iPage = 1;
clickDownMultiple2();
pending…
22m2
iEpisodeId = 22;
iPage = 2;
clickDownMultiple2();
pending…
6m
iEpisodeId = 6;
iPage = 1;
clickDownMultiple();
pending…
15m
iEpisodeId = 15;
iPage = 1;
clickDownMultiple();
pending…
22m
iEpisodeId = 22;
iPage = 2;
clickDownMultiple();
pending…

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

0 Comments