Classic property get/set vs. harmony proxy

JavaScript performance comparison

Revision 3 of this test case created by Valeriu Paloş

Info

Profile difference between regular object property accesses and access controlled by a Harmony Proxy. I wanted to see how much slower these proxies are compared to the regular properties.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var _i = 0;
   
    var A = { value: null };
   
    var B = {};
    Object.defineProperty(B, "value", {
        value: 0,
        enumerable: true,
        configurable: false,
        writable: true
    });
   
    function proxify(target) {
        return Proxy.create({
            get: function(receiver, name) {
                return target[name];
            },
            set: function(receiver, name, value) {
                target[name] = value;
                return true;
            }
        });
    }
    var C = proxify({ value: 0 });
};
</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
Classic property assignment
A.value += _i++;
pending…
Configured property assignment.
B.value += _i++;
pending…
Prototype harmony proxy assignment
C.value += _i++;
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