Meaning of proc.time()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Meaning of proc.time()

Bogaso
If I run proc.time() function, I would get following:

> proc.time()
   user  system elapsed
   2.82    4.18  792.39

However I am struggling the meaning of the object what it returned. In
help file it says that:

"user time" is the time required to execute the calling process. Here
what is the calling process exactly? Who executes this? system itself?

2ndly "system time" is the time required by the system for execution
of something.......... what execution? What is the meaning of " on
behalf of the
     calling process?"

3rdly what is elapsed time? Total time I spent on current session,
since I opened the R window?

Really sorry if I asked trivial questions, however honestly I could
not understand those. Some helpful comments are highly appreciated.

Thanks,

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Meaning of proc.time()

jholtman
This is reporting on the accumulated values of the user CPU, system
CPU and elapsed time.  The 'user + system' values indicate how much
CPU has been used to process whatever has occurred in the R session so
far.  To get the time to execute a statement, or block of code, you
can use 'system.time' or take the difference in two values of
proc.time:

> a <- proc.time()
> for(i in 1:1e6) x <- 1
> proc.time() - a  # elapsed
   user  system elapsed
   0.38    0.05   42.48
>

Here is some stuff I typed in at the console.  It took me 42 seconds
(elapsed or wall clock time) to type in the commands to the GUI.  I
executed a simple 'for' loop for 1,000,000 iteration and this required
0.43 CPU seconds (user + system).

> a <- proc.time()
> for(i in 1:1e7) x <- 1
> proc.time() - a  # elapsed
   user  system elapsed
   3.33    0.03   18.14
>

Notice that I executed the 'for' loop 10,000,000 times and the CPU
time is now 3.36 seconds, or about 10X more than the first one which
is about what you would expect.   This is a common way of determining
what portions of your script are taking the most resource.

HTH

On Tue, Jul 27, 2010 at 4:03 AM, Christofer Bogaso
<[hidden email]> wrote:

> If I run proc.time() function, I would get following:
>
>> proc.time()
>    user  system elapsed
>    2.82    4.18  792.39
>
> However I am struggling the meaning of the object what it returned. In
> help file it says that:
>
> "user time" is the time required to execute the calling process. Here
> what is the calling process exactly? Who executes this? system itself?
>
> 2ndly "system time" is the time required by the system for execution
> of something.......... what execution? What is the meaning of " on
> behalf of the
>      calling process?"
>
> 3rdly what is elapsed time? Total time I spent on current session,
> since I opened the R window?
>
> Really sorry if I asked trivial questions, however honestly I could
> not understand those. Some helpful comments are highly appreciated.
>
> Thanks,
>
> ______________________________________________
> [hidden email] 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 that you are trying to solve?

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Meaning of proc.time()

Bogaso
Ok, but what are "user CPU" and "system CPU?" If I know corrrectly, I
only have a single CPU in my system. It is not a multi-corer system.
Should I read that, system CPU time is the time that my CPU took for
actual calculation, and the user CPU time is the time that my CPU took
to analyze my code that I have written in the console?

On Tue, Jul 27, 2010 at 4:12 PM, jim holtman <[hidden email]> wrote:

> This is reporting on the accumulated values of the user CPU, system
> CPU and elapsed time.  The 'user + system' values indicate how much
> CPU has been used to process whatever has occurred in the R session so
> far.  To get the time to execute a statement, or block of code, you
> can use 'system.time' or take the difference in two values of
> proc.time:
>
>> a <- proc.time()
>> for(i in 1:1e6) x <- 1
>> proc.time() - a  # elapsed
>   user  system elapsed
>   0.38    0.05   42.48
>>
>
> Here is some stuff I typed in at the console.  It took me 42 seconds
> (elapsed or wall clock time) to type in the commands to the GUI.  I
> executed a simple 'for' loop for 1,000,000 iteration and this required
> 0.43 CPU seconds (user + system).
>
>> a <- proc.time()
>> for(i in 1:1e7) x <- 1
>> proc.time() - a  # elapsed
>   user  system elapsed
>   3.33    0.03   18.14
>>
>
> Notice that I executed the 'for' loop 10,000,000 times and the CPU
> time is now 3.36 seconds, or about 10X more than the first one which
> is about what you would expect.   This is a common way of determining
> what portions of your script are taking the most resource.
>
> HTH
>
> On Tue, Jul 27, 2010 at 4:03 AM, Christofer Bogaso
> <[hidden email]> wrote:
>> If I run proc.time() function, I would get following:
>>
>>> proc.time()
>>    user  system elapsed
>>    2.82    4.18  792.39
>>
>> However I am struggling the meaning of the object what it returned. In
>> help file it says that:
>>
>> "user time" is the time required to execute the calling process. Here
>> what is the calling process exactly? Who executes this? system itself?
>>
>> 2ndly "system time" is the time required by the system for execution
>> of something.......... what execution? What is the meaning of " on
>> behalf of the
>>      calling process?"
>>
>> 3rdly what is elapsed time? Total time I spent on current session,
>> since I opened the R window?
>>
>> Really sorry if I asked trivial questions, however honestly I could
>> not understand those. Some helpful comments are highly appreciated.
>>
>> Thanks,
>>
>> ______________________________________________
>> [hidden email] 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 that you are trying to solve?
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Meaning of proc.time()

William Dunlap
CONTENTS DELETED
The author has deleted this message.