[Rd] profiling C code

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Feb 21 08:40:06 CET 2006

On Mon, 20 Feb 2006, Liaw, Andy wrote:

> The last time I tried I didn't have much luck.  The gprof manual I could
> find seems to indicate that it can not profile code that are dynamically
> loaded.  (I was trying on Linux.)  The R source seems to hint otherwise.

grof is not mentioned in any of the R manuals, so what are your referring 
to?  (R-admin talks about `to compile a profiling version of R', not of 
shared libraries.)

> I'd very much appreciate pointers as well.

You need to use sprof rather than gprof.  Here's one relevant thread:


and I am pretty sure there have been others.

Linux has very sketchy info on sprof.  However,


has some.  I've thought about putting something about this in the
R-exts manual

> Andy
> From: Ross Boylan
>> Does anyone have any advice about profiling C/C++ code in a package
>> under R?  Does R need to be built specially for this to work?
>> The FAQ has some entries about profiling but they cover R level
>> profiling; I'm try to get at the C++ code I've written that is called
>> from R.
>> Primary target is Mac OS X.
>> Thanks.
>> Ross Boylan
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-devel mailing list