spleen387 Posted March 16, 2014 Share Posted March 16, 2014 So I've heard some things about Object.seal() being an incredible performance boost, particularly from the Construct2 creators, so I've implemented it in my constructors so that almost all instances are sealed. But I was just wondering when this is beneficial, like does an unsealed array filled with sealed objects iterate faster than an array with unsealed objects? and should a seal instance arrays when I can? Quote Link to comment Share on other sites More sharing options...
d13 Posted March 16, 2014 Share Posted March 16, 2014 Would you consider setting up a test on JSPerf? http://jsperf.com I'd love to see some hard data on reproducible test cases.There are so many factors affecting performance that you need to make sure an apparent performance boost in one area isn't just a patch for a poor architectural decision in another area. Quote Link to comment Share on other sites More sharing options...
Stunt Pixels Posted March 17, 2014 Share Posted March 17, 2014 Seems seal() is slower in Chrome, slightly quicker in FF. Be interesting to see some real world benchmarks using more than a trivial implementation though. Sample jsperf benchmarks:http://jsperf.com/object-freezehttp://jsperf.com/freeze-vs-seal-vs-normal/10http://jsperf.com/object-seal-freeze Quote Link to comment Share on other sites More sharing options...
spleen387 Posted March 19, 2014 Author Share Posted March 19, 2014 Oh, so is the real reason that construct 2 implements it is so they can ensure the objects don't have extra properties and can be "re-constructed" into new objects? becuase that's what I did. have no idea how I would test the performance for that Quote Link to comment Share on other sites More sharing options...
spleen387 Posted March 19, 2014 Author Share Posted March 19, 2014 did my first jsperf, they all seem to be pretty much the same, except seal is slightly slower Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.