micro-bench-property-get

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var key = "has", object = {has:key}, result;
    function get(object, key) {
      return object[key];
    }
    try {
    object.__defineGetter__("key", function(){
      return object[key];
    });
    }catch(o){}
    try {
    Object.defineProperty(object, "get", {
      get: function () {
        return object[key];
      }
    });
    Object.defineProperty(object, "ovl", {
      configurable: true,
      get: function () {
        return Object.defineProperty(object, "ovl", {configurable: true, value:object[key]}).ovl;
      }
    });
    }catch(o){}
};
</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 access
result = object.has;
pending…
dynamic access
result = object["has"];
pending…
dynamic access key
result = object[key];
pending…
method access
result = get(object, key);
pending…
__defineGetter__
result = object.key;
pending…
Object.defineProperty get
result = object.get;
pending…
Object.defineProperty once
result = object.ovl;
pending…
eval direct access
result = eval("object.has");
pending…
new function direct access
result = new Function("object", "return object.has")(object);
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