My computer is a pentium 4 running at 2.4 GHz. My R is 1.7.1 I have written a program in R that calls C++. The program spends most of the time in C++ ( > 90% ). R basically deals with output and input. How slower can this be compared with the program I would get from rewriting everything in C++? Thank you.
As always, it depends on your priorities and motivation. If that extra 10% is important and if you can be bothered writing the C++, then putting the whole thing into C++ may be worth it. If not then you could let R deal with the input and output. Regards, Andrew C. Ward CAPE Centre Department of Chemical Engineering The University of Queensland Brisbane Qld 4072 Australia andreww at cheque.uq.edu.au Quoting Francisco J Molina <fjmolina at lbl.gov>:> > My computer is a pentium 4 running at 2.4 GHz. > My R is 1.7.1 > > I have written a program in R that calls C++. The program > spends most of the > time in C++ ( > 90% ). R basically deals with output and > input. > How slower can this be compared with the program I would > get from rewriting > everything in C++? > > Thank you. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >
Francisco J Molina <fjmolina at lbl.gov> asked: I have written a program in R that calls C++. The program spends most of the time in C++ ( > 90% ). ... How slower can this be compared with the program I would get from rewriting everything in C++? Suppose the program takes 1 minute in R and 9 minutes in C++. Suppose you could make the R code *infinitely* faster by rewriting it in C++. Then the program would just take 9 minutes in C++. Your program would then take 90% or the time, or run 11% faster. If course, if your rewritten R code *wasn't* infinitely fast in C++, the gain would be even less. It could even be slower (because the C++ code you wrote might not be as good as the C, C++, or Fortran code that R was really spending its time in).
I must say that I agree with Andrew. I recently did just that: took an R package with C code and turn it into a stand-alone C program. Granted I'm far from being a C expert, but not only that the code didn't run any faster (because all the heavy computations were already done in C anyway), but I had to spend lots and lots of time debugging the new code. If I have the choice, I wouldn't do it. (No, I didn't have that choice...) Cheers, Andy> -----Original Message----- > From: Andrew C. Ward [mailto:s195404 at student.uq.edu.au] > Sent: Monday, July 21, 2003 10:20 PM > To: fjmolina at lbl.gov > Cc: r-help > Subject: Re: [R] R and C++ compared with only C++ > > > As always, it depends on your priorities and motivation. If > that extra 10% is important and if you can be bothered > writing the C++, then putting the whole thing into C++ may be > worth it. If not then you could let R deal with the input and output. > > Regards, > > Andrew C. Ward > > CAPE Centre > Department of Chemical Engineering > The University of Queensland > Brisbane Qld 4072 Australia > andreww at cheque.uq.edu.au > > > Quoting Francisco J Molina <fjmolina at lbl.gov>: > > > > > My computer is a pentium 4 running at 2.4 GHz. > > My R is 1.7.1 > > > > I have written a program in R that calls C++. The program > spends most > > of the time in C++ ( > 90% ). R basically deals with output and > > input. > > How slower can this be compared with the program I would > > get from rewriting > > everything in C++? > > > > Thank you. > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, ...{{dropped}}