private vs. public speed

JavaScript performance comparison

Test case created by orcaman

Info

test diff between private and public methods

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var obj = (function() {
      this.f1 = function() {
        console.log('a');
      }
      var f2 = function() {
        console.log('a')
      }
      return {
        f1: f1,
        f2: f2
      }
    })();
};
</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
use public method
obj.f1();
pending…
use private method
obj.f2();
pending…

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

Compare results of other browsers

0 comments

Add a comment