immutable-object
immutable-object copied to clipboard
Use performant Object.create replacement
trafficstars
Object.create is much slower than using the new operator in some versions of V8 (confirmed in Chrome 33 using V8 3.23, see this jsperf). This changes calls to Object.create() to a semantically-equivalent createObject() helper function that creates objects using a constructor function and the new operator.
This change also adds a basic benchmark script that can be run in node using npm run bench or served to the browser using npm run bench-server.
My benchmarks before the change:
create: 794.785ms
overwrite: 791.635ms
set: 800.428ms
And after the change:
create: 19.083ms
overwrite: 17.687ms
set: 15.335ms