Hi R users, I have mentioned that R is getting slower if a process with a loop runs for a while. Is that normal? Let's say, I have a code which produce an output file after one loop run. Now after 10, 15 or 20 loop runs the time between the created files is stongly increasing. Is there maybe any data which fill some memory? Chris -- View this message in context: http://r.789695.n4.nabble.com/R-process-slow-down-after-a-amount-of-time-tp4664358.html Sent from the R help mailing list archive at Nabble.com.
R. Michael Weylandt <michael.weylandt@gmail.com>
2013-Apr-16 14:04 UTC
[R] R process slow down after a amount of time
On Apr 16, 2013, at 9:52 AM, Chris82 <rubenbauar at gmx.de> wrote:> Hi R users, > > I have mentioned that R is getting slower if a process with a loop runs for > a while. Is that normal? > Let's say, I have a code which produce an output file after one loop run. > Now after 10, 15 or 20 loop runs the time between the created files is > stongly increasing. > Is there maybe any data which fill some memory?Possibly, but I were to put money on it, I'd guess there's an ever-expanding object problem: x <- NULL for(i in 1:1e6) x <- c(x, rnorm(1)) which is not-so-secretly quadratic and should instead be: x <- rnorm(1e6) Perhaps a small reproducible example would help us help you. Michael> > > Chris > > > > -- > View this message in context: http://r.789695.n4.nabble.com/R-process-slow-down-after-a-amount-of-time-tp4664358.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Le 16/04/13 15:52, Chris82 a ?crit :> Hi R users, > > I have mentioned that R is getting slower if a process with a loop runs for > a while. Is that normal? > Let's say, I have a code which produce an output file after one loop run. > Now after 10, 15 or 20 loop runs the time between the created files is > stongly increasing. > Is there maybe any data which fill some memory? > > > Chris >I try your idea but I don't find anyt time difference. Could you more explicit ? Marc ##### loop time ###### tm <- rep(Sys.time(), 1000) k <- 1 for (i in 1:1e7) { if (i%%10000==0) { tm[k] <- Sys.time() k <- k+1 } } plot(1:999, diff(tm), bty="n", type="l", ylim=c(0, 0.05)) -- __________________________________________________________ Marc Girondot, Pr Laboratoire Ecologie, Syst?matique et Evolution Equipe de Conservation des Populations et des Communaut?s CNRS, AgroParisTech et Universit? Paris-Sud 11 , UMR 8079 B?timent 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.girondot at u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot