[R] R and C++ compared with only C++

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue Jul 22 05:30:30 CEST 2003


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).




More information about the R-help mailing list