[R] System.time

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu Feb 12 11:11:39 CET 2009


Gavin Simpson wrote:
> On Wed, 2009-02-11 at 18:49 -0600, John Kerpel wrote:
>   
>> Hi folks!
>> Does anyone know why I might see something like this after running
>> system.time?
>>
>> system.time(svd(Mean_svd_data))
>>    user  system elapsed
>>       0       0       0
>>
>> The data set is tiny and the function returns results instantly, but
>> shouldn't it still give me a time?
>>     
>
> Jim has already suggested why this might be the case. When I'm testing
> the speed of things like this (that are in and of themselves very quick)
> for situations where it may matter, I wrap the function call in a call
> to replicate():
>
> system.time(replicate(1000, svd(Mean_svd_data)))
>
> to run it 1000 times, and that allows me to judge how quickly the
> function executes.
>
>   


the timethese function in the Benchmark module in perl takes as
arguments not only the code to be run, but also the number of
replications to be performed.  it will complain if the code runs too
fast, i.e., if the measured time is too short and is not a reliable
estimate.

it might be a good idea to have a similar functionality in r (maybe it's
already there?), which would basically wrap over system.time and issue a
warning when reliable measurement canno tbe made.

vQ




More information about the R-help mailing list