system.time               package:base               R Documentation

_C_P_U _T_i_m_e _U_s_e_d

_D_e_s_c_r_i_p_t_i_o_n:

     Return CPU (and other) times that 'expr' used.

_U_s_a_g_e:

     system.time(expr, gcFirst = TRUE)
     unix.time(expr, gcFirst = TRUE)

_A_r_g_u_m_e_n_t_s:

    expr: Valid R expression to be "timed"

 gcFirst: Logical - should a garbage collection be performed
          immediately before the timing?  Default is 'TRUE'.

_D_e_t_a_i_l_s:

     'system.time' calls the function 'proc.time', evaluates 'expr',
     and then calls 'proc.time' once more, returning the difference
     between the two 'proc.time' calls.

     'unix.time' is an alias of 'system.time', for compatibility with
     S.

     Timings of evaluations of the same expression can vary
     considerably depending on whether the evaluation triggers a
     garbage collection. When 'gcFirst' is 'TRUE' a garbage collection
     ('gc') will be performed immediately before the evaluation of
     'expr'. This will usually produce more consistent timings.

_V_a_l_u_e:

     A object of class '"proc_time"': see 'proc.time' for details.

_N_o_t_e:

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

_S_e_e _A_l_s_o:

     'proc.time', 'time' which is for time series.

_E_x_a_m_p_l_e_s:

     require(stats)
     system.time(for(i in 1:100) mad(runif(1000)))
     ## Not run: 
     exT <- function(n = 1000) {
       # Purpose: Test if system.time works ok;   n: loop size
       system.time(for(i in 1:n) x <- mean(rt(1000, df=4)))
     }
     #-- Try to interrupt one of the following (using Ctrl-C / Escape):
     exT()                 #- about 3 secs on a 1GHz PIII
     system.time(exT())    #~ +/- same
     ## End(Not run)

