Hello all: I am in the process of building a UI framework in JS using ECMA5 whenever possible. I love the new Object.create and Object.defineProperty syntax with the ability to cleanly add accessor methods.
I have been doing some profiling of various accessor techniques and have consistently found Object.defineProperty to be much slower than property syntax and normal function definitions. For reference please see: http://jsperf.com/getter-setter/6 This isn't a small difference, on my machine I was getting something like 230 million ops/s vs 1.4 million ops/s. I have done further tests to get a sense of real world usage. For example, I have created a WebGL animation library and toggled between using functions and properties defined with defineProperty: object.getX() / object.setX() vs object.x As the number of objects increases the property syntax shows a clear decrease in performance over the function calls, somewhere in the range of 6 to 10 fps. I am not sure this is due to the perhaps v8 (and in general all JS engines) being optimized for function syntax over ECMA5 syntax or perhaps the extra baggage that comes with the latter, namely the writable, configurable, and enumerable attributes. Just curious if I am the only one who has seen this. Thanks. -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
