Classic property get/set vs. harmony proxy.

JavaScript performance comparison

Revision 5 of this test case created by rektide

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.

For Chrome, please activate Harmony proxy support by enabling the option named "Enable Experimental JavaScript" in "chrome://flags/" page.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var _i = 0, _j = 0, _k = 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 += _j++;
pending…
Prototype harmony proxy assignment.
C.value += _k++;
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