J.delasHeras at ed.ac.uk
2009-Sep-03 15:42 UTC
[R] Calling R from a Perl script: much slower?
Hello list, I use R for microarray analysis. One procedure I use takes a large matrix, and loops through it looking for specific rows, does an operation with them, and outputs a result (single row) as a row of another matrix. The loop goes on about 25000 times. When I run the loop directly from the R console itself, it takes about 3 minutes in my computer. I'm ok with that. Now, when that same code is ran from within a GUI we created using Perl (Tcl/Tkx) it's taking 25-30 minutes to run. Within the R code I inserted a line so that it writes a little file every 1000th iteration of the loop, so that I can follow the progress. I don't understand why it takes 10x longer when ran from Perl. I am not new to R, but I am new to using it within Perl or any other language. Is there a way to improve performance? What is the reason for the slower speed? I'll happily provide the code if somebody wants it. thank you. Jose -- Dr. Jose I. de las Heras Email: J.delasHeras at ed.ac.uk The Wellcome Trust Centre for Cell Biology Phone: +44 (0)131 6513374 Institute for Cell & Molecular Biology Fax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK ********************************************* NEW EMAIL from July'09: nach.mcnach at gmail.com ********************************************* -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
What operating system are you running under? You should take a look at the R process and see how much time it is using to see if there is a difference in the CPU time. Are you paging? Exactly how are you invoking the R script? Why are you using the GUI instead of Rterm? You might try to run Rprof on the code to see if there are differences. Are you sure you are running exactly the same data in both cases? On Thu, Sep 3, 2009 at 11:42 AM, <J.delasHeras at ed.ac.uk> wrote:> > Hello list, > > I use R for microarray analysis. > One procedure I use takes a large matrix, and loops through it looking for > specific rows, does an operation with them, and outputs a result (single > row) as a row of another matrix. The loop goes on about 25000 times. > > When I run the loop directly from the R console itself, it takes about 3 > minutes in my computer. I'm ok with that. > > Now, when that same code is ran from within a GUI we created using Perl > (Tcl/Tkx) it's taking 25-30 minutes to run. > > Within the R code I inserted a line so that it writes a little file every > 1000th iteration of the loop, so that I can follow the progress. I don't > understand why it takes 10x longer when ran from Perl. > > I am not new to R, but I am new to using it within Perl or any other > language. Is there a way to improve performance? What is the reason for the > slower speed? > > I'll happily provide the code if somebody wants it. > > thank you. > > Jose > > -- > Dr. Jose I. de las Heras ? ? ? ? ? ? ? ? ? ? ?Email: J.delasHeras at ed.ac.uk > The Wellcome Trust Centre for Cell Biology ? ?Phone: +44 (0)131 6513374 > Institute for Cell & Molecular Biology ? ? ? ?Fax: ? +44 (0)131 6507360 > Swann Building, Mayfield Road > University of Edinburgh > Edinburgh EH9 3JR > UK > ********************************************* > NEW EMAIL from July'09: nach.mcnach at gmail.com > ********************************************* > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
On 09/03/2009 05:42 PM, J.delasHeras at ed.ac.uk wrote:> > > Hello list, > > I use R for microarray analysis. > One procedure I use takes a large matrix, and loops through it looking > for specific rows, does an operation with them, and outputs a result > (single row) as a row of another matrix. The loop goes on about 25000 > times. > > When I run the loop directly from the R console itself, it takes about 3 > minutes in my computer. I'm ok with that. > > Now, when that same code is ran from within a GUI we created using Perl > (Tcl/Tkx) it's taking 25-30 minutes to run. > > Within the R code I inserted a line so that it writes a little file > every 1000th iteration of the loop, so that I can follow the progress. I > don't understand why it takes 10x longer when ran from Perl. > > I am not new to R, but I am new to using it within Perl or any other > language. Is there a way to improve performance? What is the reason for > the slower speed? > > I'll happily provide the code if somebody wants it. > > thank you. > > JoseCan you describe what you mean by "running the code from the gui". Is R embedded in you application or do you create a new R session each time. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/xMdt : update on the ant package |- http://tr.im/xHLs : R capable version of ant `- http://tr.im/xHiZ : Tip: get java home from R with rJava