[Rd] Probem with argument "append" in "Rprof"
Thomas Lumley
tlumley at u.washington.edu
Wed Apr 4 17:19:42 CEST 2007
Thanks for this. I will look at it over the weekend.
-thomas
On Sun, 1 Apr 2007, Romain Francois wrote:
> .... And now I realize I gave the patches in the wrong order, let me try
> again
>
> Cheers,
>
> Romain
>
> Romain Francois wrote:
>> [forgot to attach the second patch in the first mail, sorry.]
>>
>> Hello,
>>
>> Appending information to the profiler's output seems to generate
>> problems. Here is a small example of code :
>>
>> <code r>
>> require(boot)
>> Rprof( memory.profiling = TRUE)
>> Rprof(NULL)
>> for(i in 1:2){
>> Rprof( memory.profiling = TRUE, append = TRUE)
>> example(boot)
>> Rprof(NULL)
>> }
>> </code>
>>
>> The problem is that the file Rprof.out contains more than once the
>> header information:
>>
>> $ grep "sample.interval=" Rprof.out
>> memory profiling: sample.interval=20000
>> memory profiling: sample.interval=20000
>> memory profiling: sample.interval=20000
>>
>> and `summaryRprof` or `R CMD Rprof` are not dealing with it
>>
>>
>>> idx <- grep( "sample", rownames( smp <- summaryRprof()[[1]] ) );
>>>
>> smp[idx, ]
>> self.time self.pct total.time total.pct
>> sample.interval=20000 0 0 0.04 0.1
>>
>> `sample.interval=20000` is incorrectly considered as a function.
>>
>>
>> This is not too much of a big deal, but then if I ask for memory
>> profiling information as well, I get nothing:
>>
>>
>>> summaryRprof( mem = "stats")
>>>
>> Error in tapply(1:1L, list(index = c("sample.interval=20000:profiling:", :
>> arguments must have same length
>>
>>> summaryRprof( mem = "tseries")
>>>
>> Error in data.frame(..., check.names = FALSE) :
>> arguments imply differing number of rows: 1, 1490
>>
>>> summaryRprof( mem = "both")
>>>
>> Error in apply(sapply(strsplit(memstuff, ":"), as.numeric), 1, diff) :
>> dim(X) must have a positive length
>>
>> $ R CMD Rprof Rprof.out
>>
>> Each sample represents seconds.
>> Total run time: 0 seconds.
>>
>> Total seconds: time spent in function and callees.
>> Self seconds: time spent in function alone.
>>
>> % total % self
>> total seconds self seconds name
>> Illegal division by zero at /usr/local/lib/R/bin/Rprof line 91, <> line
>> 1491.
>>
>> A quick fix could be to ignore all the lines containing sample.interval=
>> except the first one, but then if someone wants to actually change the
>> interval argument in Rprof, it would not be correct. I attach a patch
>> against R-devel/src/library/utils/R/summRprof.R to do that anyway, but I
>> will look at a better solution.
>>
>> I am not fluent enough in Perl to do the same in the Rprof script, it
>> looks like it does not handle the memory profiling information anyway. I
>> am about to learn Perl, so I guess it could be a useful way to do it. I
>> also attach a patch against R-devel/src/scripts/Rprof that would at
>> least get rid of the memory profiling information (if any). This is not
>> as good as dealing with it, but ... this is the first time I ever touch
>> a Perl script.
>>
>>
>> Cheers,
>>
>> Romain
>>
>>
>>
>>
>>> version
>>>
>>
>> _
>> platform
>> i686-pc-linux-gnu
>> arch
>> i686
>> os
>> linux-gnu
>> system i686,
>> linux-gnu
>> status Under development
>> (unstable)
>> major
>> 2
>> minor 6.0
>> year
>> 2007
>> month
>> 03
>> day
>> 30
>> svn rev
>> 40983
>> language
>> R
>> version.string R version 2.6.0 Under development (unstable) (2007-03-30
>> r40983)
>>
> --
> Mango Solutions
> data analysis that delivers
>
> Tel: +44(0) 1249 467 467
> Fax: +44(0) 1249 467 468
> Mob: +44(0) 7813 526 123
>
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-devel
mailing list