function caching

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var ns = {};
   
    function sum(a,b) {
      function rsum(a,b) {
        return a + b;
      }
      return rsum(a,b);
    }
   
    function csum(a,b) {
      if(!ns.rsum) {
        ns.rsum = function (a,b) {
          return a + b;
        }
      }
      return ns.rsum(a,b);
    }
};
</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
no cache
sum(1,2);
pending…
caching
csum(1,2)
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