[R] Profiling R code and C code (Rprof and gprof)
Yongchao Ge
Yongchao.Ge at mssm.edu
Wed Feb 16 14:46:57 CET 2005
Hi,
I have searched R mail list archive and couldn't find my answers. The R
extension describes how to make use of Rprof to profile R code.
gprof can be also used for the same purpose for the
C codes when the C codes are written independently and provided with a
main() function.
I'm currently writing R codes meshed with C Codes, and use .Call as the
interface between the two parts. Rprof reports details of each R
functions, but does not report the details of the C functions.
I'm wondering if there is a way such that Rprof can report the detials of
each C functions as did in gprof.
One may suggest I can compile all of the C codes and write a main
function, and then use the gprof. That's definitely true before I moved from .C to
.Call. Since now the R codes and C codes are meshed in the same program,
it does not seem a trivial job to separate the two parts neatly.
We can use "R -d gdb" to debug C codes meshed with R codes. If we can also
profile the C functions called by the R codes, then it will much be
productive to write useful C codes.
Any suggestions how to use Rprof and gprof to help me to spot a C
function which I can work on to speed up my program will be much
appreciated.
Thanks,
Yongchao
More information about the R-help
mailing list