tracker            package:RUnit            R Documentation(latin1)

_T_r_a_c_k_i_n_g _t_h_e _r_e_s_u_l_t_s _o_f _t_h_e _i_n_s_p_e_c_t _p_r_o_c_e_s_s.

_D_e_s_c_r_i_p_t_i_o_n:

     The current implementation uses the 'closure trick' to hide all
     details from the user and only allows to retrieve the results of
     the code inspection. 'tracker' is used to create a new environment
     to manage and store the results of the tracking process. The
     'inspect' function requires such an environment with the name
     "track" (currently mandatory). The tracker records how often each
     and every function was called by 'inspect' and summarizes the
     results of all calls. 'tracker$init' initializes the tracker
     environment. 'tracker$getTrackInfo' returns a list with the
     tracked results of the inspection process.

_U_s_a_g_e:

     tracker()

_D_e_t_a_i_l_s:

     The 'trackInfo' S3 class object (list) has one entry for each
     function on the inspect list with the following elements:

     _s_r_c The source code of the function.

     _r_u_n The number of executions for each line of code.

     _g_r_a_p_h A matrix. Each element in the matrix counts how often a code
          line was called from the previous code line in the execution
          flow.

     _n_r_R_u_n_s Counts how often the function was called.

     _f_u_n_c_C_a_l_l The declaration of the function.

_M_e_t_h_o_d_s:


         'init'          initializes the tracker environment
         'addFunc'       add function to the inspect tracking list (internal use)
         'getSource'     return the modified source code used for during inspection  the specified index (internal use)
         'bp'            update tracking info for specified function index (internal use)
         'getTrackInfo'  return 'trackInfo' object
         'isValid'       check 'trackInfo' object for conformance to class contract

_A_u_t_h_o_r(_s):

     Thomas Koenig, Klaus Juenemann & Matthias Burger

_S_e_e _A_l_s_o:

     'inspect' for the registration of functions & methods to be on the
     tracking list.

_E_x_a_m_p_l_e_s:

     ## example functions
     foo <- function(x){
        y <- 0
        for(i in 1:100)
        {
           y <- y + i
        }
        return(y)
     }

     bar <- function(x){
        y <- 0
        for(i in 1:100)
        {
           y <- y - i
        }
        return(y)
     }


     ##  the object name track is 'fixed' (current implementation)
     track <- tracker()

     ##  initialize the tracker
     track$init()

     ##  inspect the function
     ##  resFoo1 will contain the result of calling foo(50)
     resFoo1 <- inspect(foo(50), track = track)

     resFoo2 <- inspect(foo(20), track = track)

     resBar1 <- inspect(bar(30), track = track)

     ##  get the tracked function call info for all inspect calls
     resTrack <- track$getTrackInfo()

     ##  create HTML sites in folder ./results for all inspect calls
     printHTML.trackInfo(resTrack)

