[R] run-time of an R function

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Jan 16 19:29:04 CET 2006


Rossi, Peter E. wrote:

> I have noticed dramatic differences in the run-time for the execution of
> one of my functions depending on whether or not R was restarted.
> Immediately
> after restart of R GUI, exec time = 2.8 min. If I then repeat the
> execution
> of the function in the same R session, exec time = 7.1 min. Removing all
> objects via rm(list=(all=TRUE)) and initiating gc (gc(reset=TRUE))
> helps, but
> only slightly (exec time = 5.0 min). 
> 
> any thoughts on why this happens? 


Quite probably due to memory fragmentation.
Smaller objects and more RAM might help a little bit.

Uwe Ligges


> I realize that this is somewhat of a generic question given that I
> haven't
> provided the source code for the function.  However, the function
> is very involved so that I think presenting it might violate the posting
> guidelines. The function creates and recreates large list structures
> and calls numerical functions on elements of these lists.  The list
> structures
> can be nested several levels deep, e.g. a list of lists.
> 
> Are there particular aspects of R function programming to watch out for
> that can create this sort of problem?
> 
> I'm running windows R v 2.2.1
> 
> thanks!
> 
> peter r
>  
> 
> ................................
>   Peter E. Rossi
>  Joseph T. and Bernice S. Lewis Professor of Marketing and Statistics
>  Editor, Quantitative Marketing and Economics
>  Rm 353, Graduate School of Business, U of Chicago
>  5807 S. Woodlawn Ave, Chicago IL 60637, USA
>  Tel: (773) 702-7513   |   Fax: (773) 834-2081
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list