Private or not Private

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function PrivateFoo(paramOne) {
      var thisIsPrivate = paramOne;
   
      this.bar = function() {
        return thisIsPrivate;
      };
    }
   
    function PublicFoo(paramOne) {
      this._thisIsPrivate = paramOne;
    }
   
    PublicFoo.prototype.bar = function() {
      return this._thisIsPrivate;
    };
};
</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
Private
var foo = new PrivateFoo("Hello, Privacy!");
var result = foo.bar();
pending…
Public
var foo = new PublicFoo("Hello, Privacy!");
var result = foo.bar();
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