Hi guys, perhaps somebody can shed some light on this, especially in regards
to the recent postings about performance issues regarding the mutability of
the prototype chain and arguments.  A pattern that I rely on quite heavily
is to create one class that is a subclass of another.  I use a pretty
standard extend function that sets up the prototype chain to create a
class hierarchy.  I was reading all of the posts involving the performance
penalties of using "arguments" and thought to myself, "I use arguments all
over the place, every time I call a super class's overridden function."  I
set up a performance test in jsperf (
http://jsperf.com/call-vs-apply-with-arguments) and was a bit surprised at
the results of using call vs apply with an empty array vs apply with
arguments.

But basically, from all the talk of using arguments having a performance
penalty, I was expecting that functionReference.apply( this, arguments )
would be very slow and functionReference.call( this ) to be the fastest -
and this indeed is generally the case.  But Chrome 10 and Opera 11 are
standouts.  In Chrome 10, functionReference.apply( this, arguments ) is
several million ops per second faster than functionReference.call( this ).
 In Opera 11, functionReference.apply( this, [] ) is the fastest by a long
shot and functionReference.apply( this, arguments ) is the slowest, about 6
million ops/second slower than when using an empty array for the arguments.

Can anybody shed some light on this as to why?  I realize it is probably a
micro-optimization and I don't need to change my code in most places, but I
was thinking if I ever came into a performance critical loop where a
superclass' function was called, this could start to become an issue.

http://jsperf.com/call-vs-apply-with-arguments

Thanks,
Shane

-- 
---------------------------------------------------
http://www.shanetomlinson.com
http://www.aframejs.com - a Javascript MVC library making traditional app
development in the browser much easier

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to