another-js-get

JavaScript performance comparison

Test case created by WebReflection

Info

Performance gap using AnotherJS Object#get(key) VS direct, dynamic, and getter accessor.

https://github.com/WebReflection/another-js

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var
      object = {test:Math.random()},
      key = "test",
      getter = (Object.defineProperties || Object)({}, {
        test: {
          configurable: true,
          enumerable: true,
          get: function () {
            return this["_" + key];
          }
        }
      }),
      result
    ;
    getter["_" + key] = object.test;
   
    // another-js getter
    Object.prototype.get = function get(key) {
      return this[key];
    };
};

Benchmark.prototype.teardown = function() {
    delete Object.prototype.get;
};
</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
direct
result = object.test;
pending…
indirect
result = object[key];
pending…
getter direct
result = getter.test;
pending…
getter indirect
result = getter[key];
pending…
another-js get direct
result = object.get("test");
pending…
another-js get indirect
result = object.get(key);
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