Dear R-users
In order to speed up the performance of my program I tried to make a
function f2 (that is only called from function f1) local to f1. In that way I
pass one argument less to f2, a huge matrix. (This matrix isn't changed
inside f2, so - afaik - it is passed by reference and size doesn't matter.)
Still I would have expected that f1 would be a little faster, but the
opposit happened:
system.time(
rs <- rotateSegment(im, 272, 234, 100, 72, 51, 21)
)
(where rotateSegment is f1)
gave
> + + [1] 12.13 0.05 12.31 0.00 0.00 ## f2 extern of f1
> + + [1] 12.29 0.02 12.46 0.00 0.00 ## f2 local to f1
(I tried several times and got always similar results. I am using Linux,
Red Hat 6.1)
Does the use of local functions generally slow down the performance? (Even
though just a little bit, whereas the advantage of elegancy in programming
might be considered quite big.)
Peter
____________________________________________________________
Peter Holzer phone: + 41 1 632 46 34
Seminar fuer Statistik, LEO C14 fax: + 41 1 632 12 28
(Leonhardstr. 27) <holzer at stat.math.ethz.ch>
ETH (Federal Inst. Technology)
8092 Zurich http://www.stat.math.ethz.ch/~holzer/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._