Re: [R] system.time()

From: jim holtman <jholtman_at_gmail.com>
Date: Sat, 26 Apr 2008 20:47:35 -0400

The first two numbers will not add up to the third. The third is the elapsed time (wall clock) and the first two are CPU time; even though they have what appears to be the same units (seconds), they can not really be compared. If, for example, was script was taking input from the console, you will get something like this:

> system.time({

+ x <- scan("")
+ })
1: 12345
2:
Read 1 item

   user system elapsed
   0.00 0.06 7.34
>

Here it took 7 seconds for me to enter the data, on only 0.06 seconds of CPU (all system time -- probably the 'read' function).

The differences in your numbers were the CPU is larger than the elapsed might be due to the resolution of the time since it was a very short time, or if you are running an a multiprocessor, and the application can run multithreaded, you will see the same thing happen -- e.g., if you have 2 CPU and the application could multithread and it was CPU bound, then in 10 seconds of elapsed time you might see 20 seconds of CPU time being used.

HTH On Sat, Apr 26, 2008 at 8:32 PM, Fernando Saldanha <fsaldan1_at_gmail.com> wrote:
> I thought system.time() would return three numbers, the first two
> adding up to the third one. However, this does not hold in my system
> running Windows Vista Home Premium, with an Intel Core 2 Duo
> processor. For example, using the code in the help for system.time()
> (with one zero added), I got:
>
> > system.time(for(i in 1:100) mad(runif(10000)))
> user system elapsed
> 0.27 0.00 0.25
>
> Is this a problem with my system clock or am I missing something?
>
> Thanks.
>
> FS
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 27 Apr 2008 - 00:55:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 Apr 2008 - 06:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive