Joined October 2013
·
Posted to
The prototype is your friend (if you care about perf)
over 1 year
ago
You should see my reddit comment http://www.reddit.com/r/javascript/comments/1nnkfe/the_prototype_is_your_friend_if_you_care_about/ccm0rw6
In the fixed jsperf, prototype method invocation is "only" 1.5x faster. Even if we ignore for a second that this difference is huge for such a low level operation, we cannot look at the 1.5x at face value because the difference comes from the ability to do inlining.
Achievements
108 Karma
0 Total ProTip Views

Honey Badger
Have at least one original Node.js-specific repo

Forked 100
Have a seriously badass project that's been forked at least 100 times

Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos

Altruist
Increase developer well-being by sharing at least 20 open source projects

Kilo of Lemmings
Establish a space in the open source hall of fame by getting at least 1000 devs to watch a project

Forked 50
Have a project with a thriving community of users that's been forked at least 50 times

Lemmings 100
Write something great enough to have at least 100 watchers of the project

Forked 20
Have an established project that's been forked at least 20 times

Forked
Have a project valued enough to be forked by someone else

Charity
Fork and commit to someone's open source project in need

Cub
Have at least one original jQuery or Prototype open source repo
@dtao I am trying actually trying to defend your point. Many people shrug off object creation because they are "not creating that many objects anyway". Anyway, in object creation you have O(n) vs O(1) so there is no fair benchmark. If you benchmark a class of say, 25 methods, you will easily get like 10000x difference. And again many people only benchmark with one method (so they compare O(N) to O(1) with N=1, lol).
My point is that it should already be obvious to everyone that the object creation will be extremely slow when methods are re-recreated instead of placed on prototype.
This opens up comparison of method calls rather than object creation, where I am again trying to explain that 1.5x difference is not what it looks like and there is much bigger difference in practice even between method calls of "prototype class" vs "closure class"