proc.time                package:base                R Documentation

_R_u_n_n_i_n_g _T_i_m_e _o_f _R

_D_e_s_c_r_i_p_t_i_o_n:

     'proc.time' determines how much real and CPU time (in seconds) the
     currently running R process has already taken.

_U_s_a_g_e:

     proc.time()

_D_e_t_a_i_l_s:

     'proc.time' returns five elements for backwards compatibility, but
     its 'print' method prints a named vector of length 3.  The first
     two entries are the total user and system CPU times of the current
     R process and any child processes on which it has waited, and the
     third entry is the 'real' elapsed time since the process was
     started.

_V_a_l_u_e:

     An object of class '"proc_time"' which is a numeric vector of
     length 5, containing the user, system, and total elapsed times for
     the currently running R process, and the cumulative sum of user
     and system times of any child processes spawned by it on which it
     has waited.  (The 'print' method combines the child times with
     those of the main process.)

     The definition of 'user' and 'system' times is from your OS. 
     Typically it is something like

     _The 'user time' is the CPU time charged for the execution of user
     instructions of the calling process. The 'system time' is the CPU
     time charged for execution by the system on behalf of the calling
     process._

     The resolution of the times will be system-specific and on
     Unix-alikes times are rounded to the nearest 1ms.  On modern
     systems they will be that accurate, but on older systems they
     might be accurate to 1/100 or 1/60 sec.

     This is a primitive function.

_N_o_t_e:

     It is possible to compile R without support for 'proc.time', when
     the function will throw an error.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'system.time' for timing a valid R expression, 'gc.time' for how
     much of the time was spent in garbage collection.

_E_x_a_m_p_l_e_s:

     ## Not run: 
     ## a way to time an R expression: system.time is preferred
     ptm <- proc.time()
     for (i in 1:50) mad(stats::runif(500))
     proc.time() - ptm
     ## End(Not run)

