it seems, that the closure way is faster.
it was just the creation of functions whenever the closure was executed,
while the prototype version uses the same function,
so a proper comparison would be:
http://jsperf.com/prototypemodule-vs-closuremodule/9
i used
"var api = {...};" just to reference "api.x" in methods
even though it still gets rid of "prototype" and "new", it still uses
"this" :-(
But maybe in a real world example, if i would just replace methods like:
appeal: appeal,
snark: snark
with something like
appeal: function () { return appeal(api); },
snark: function () {return snark(api); }
of course with the need to adapt "appeal" and "snark" accordingly by
replacing "this" with "api",
it should not matter much anymore, right?
after all - its still quite fast and at least i got rid of "this" :-)
2015-01-13 7:22 GMT+01:00 jules <[email protected]>:
> Le lundi 12 janvier 2015, 17:00:21 Alexander Praetorius a écrit :
> > Maybe that test has to be refined?
>
> like this?
> http://jsperf.com/prototypemodule-vs-closuremodule/6
>
> v8 made some optimizations on "prototype" way
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/1581449.3jv6NryCTy%40homer.
> For more options, visit https://groups.google.com/d/optout.
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAN5%2BLUu2Ez4pbZDGwRa-_uZkw3uvHBCy5n%3DKiAn5yt1tSdJsSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.