Object Sealing Benefits?

Discussion and feedback on Construct 2

Post » Tue Apr 01, 2014 12:17 am

Hi @Ashley,

I was just reading this page recently and was wondering as to how much benefit that sealed objects bring. I found and ran a test here on JSPerf, and what I'm seeing is that in fact the extra security actually SLOWS down the property access. Let me know what you think.
Jack of all trades, and master of some.
B
31
S
10
G
7
Posts: 176
Reputation: 7,806

Post » Tue Apr 01, 2014 4:13 am

Chrome really suffer a lot of performance with the example or test method.
B
84
S
24
G
14
Posts: 391
Reputation: 12,658

Post » Tue Apr 01, 2014 10:02 am

Yeah, we actually turned off object sealing in the runtime a long time ago because it had a pretty big performance impact on some systems. I've removed that section from the SDK manual now. Still though it's a good idea performance-wise to pretend the objects are sealed, because JS engines can't optimise well for objects with dynamic properties - create all properties you need in onCreate and only use those in your code.
Scirra Founder
B
403
S
238
G
89
Posts: 24,659
Reputation: 196,165

Post » Tue Apr 01, 2014 4:13 pm

Good to know, thanks. :)

Edit: Though, it does occur to me to note that C2 recycles the object instances, and most likely only clears all properties (hopefully, instead of deleting them), so in effect, properties set should never be set again in practice (so no dynamic issues to worry about). :)
Jack of all trades, and master of some.
B
31
S
10
G
7
Posts: 176
Reputation: 7,806


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests