From ripley at stats.ox.ac.uk  Sat Feb 26 09:17:12 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sat Feb 26 09:17:21 2005
Subject: [Rd] Profiling C functions called from R.
In-Reply-To: <421FD69C.8000707@stat.washington.edu>
References: <421FD69C.8000707@stat.washington.edu>
Message-ID: <Pine.LNX.4.61.0502260757000.19634@gannet.stats>

On Fri, 25 Feb 2005, Pavel N. Krivitsky wrote:

> Hi,
>
> I am working on an R package which includes some C routines. I would like to 
> profile the C routines (built with GCC under Debian Linux). I tried running R 
> with
>
> LD_PROFILE=/path/to/C/library.so R
>
> and executing functions that would invoke the code therein. The code takes 
> about twice as long to run with LD_PROFILE set than without, so I am guessing 
> that profiling is taking place. However, gmon.out is not generated (or at 
> least I can't find it anywhere on the filesystem).
>
> Has anyone been able to profile shared libraries built for R in Linux?

How exactly are you trying to do this?  Is R built to support profiling 
(see the R-admin manual)?  Are you using gprof or sprof?

I would not expect that setting to produce a gmon.out (I think you have 
confused gprof and sprof).   At least on Solaris, with this route you need 
not to have used -pg and you get a file like /var/tmp/foo.so.profile.
Linux's documentation is far, far sketchier.

-- 
Brian D. Ripley,                  ripley@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


[Rd] Profiling C functions called from R.
Prof Brian Ripley