3 ms·
Currently doing Object.freeze closes the door for optimizations: object goes into so called slow mode. See http://jsperf.com/object-freeze http://jsperf.com/ob
by mraleph 16y ago
Currently doing Object.freeze closes the door for optimizations: object goes into so called slow mode.
See http://jsperf.com/object-freeze http://jsperf.com/object-freeze results.
- swannodette 16y agohttp://jsperf.com/object-freeze/3 http://jsperf.com/object-freeze/3 http://jsperf.com/object-freeze/5 http://jsperf.com/object-freeze/5 http://jsperf.com/object-freeze/6 http://jsperf.com/object-freeze/6 A reminder on how immutable objects are meant to be used. When used properly even under attempts to mutate, they run circles around trying to use mutable objects in an immutable manner.
- mraleph 16y agoYeah, I did something stupid in my own test. Probably I was thinking about Object.seal(). Nevertheless your own test revision #3 shows that accesses to frozen properties are roughly 14 times slower. Revisions #5 and #6 do an allocation in the "hot" testcase so the real cost of property lookup just becomes hidden behind cost of memory management.