Message-ID: <42891A0A.6090507@stats.uwo.ca>
Date: 2005-05-16T22:09:14Z
From: Duncan Murdoch
Subject: parsing speed
In-Reply-To: <1116240414.23816.70.camel@localhost.localdomain>
Federico Calboli wrote:
> Hi everyone,
>
> I have a question on parsing speed.
>
> I have two functions:
>
> F1
> F2
>
> As things are now, F2 calls F1 internally:
>
> F2 = function(x){
> if (something == 1){
> y = F1(x)
> }
> if (something ==2){
> do whatever
> }
> }
>
> *Assuming there could be some difference*, is is faster to use the code
> as written above or should I actually write the statements of F1 to make
> the parsing faster?
The parsing only happens once when you define the functions, and is
(almost always) a negligible part of total execution time. I think
you're really worried about execution time. You'll probably get more
execution time with a separate function because function calls take time.
However, my guess is that putting F1 inline won't make enough difference
to notice.
Duncan