profr: Profile the performance of a function call.

Description Usage Arguments Details Value See Also Examples

View source: R/profile.r

Description

This is a wrapper around Rprof that provides results in an alternative data structure, a data.frame. The columns of the data.frame are:

Usage

1
profr(expr, interval = 0.02, quiet = TRUE)

Arguments

expr

expression to profile

interval

interval between samples (in seconds)

quiet

should output be discarded?

Details

f

name of function

level

level in call stack

time

total time (seconds) spent in function

start

time at which control entered function

end

time at which control exited function

leaf

TRUE if the function is a terminal node in the call tree, i.e. didn't call any other functions

source

guess at the package that the function came from

Value

data.frame of class profr

See Also

parse_rprof to parse standalone Rprof file, plot.profr and ggplot.profr to visualise the profiling data

Examples

1
2
3
4
5
6
7
## Not run: 
glm_ex <- profr({Sys.sleep(1); example(glm)}, 0.01)
head(glm_ex)
summary(glm_ex)
plot(glm_ex)

## End(Not run)

Example output

   level g_id t_id                f start  end n  leaf time source
8      1    1    1       doTryCatch  0.00 0.06 1 FALSE 0.06   <NA>
9      2    1    1            force  0.00 0.06 1 FALSE 0.06   base
10     3    1    1          example  0.00 0.06 1 FALSE 0.06  utils
11     4    1    1     tools::Rd2ex  0.00 0.01 1 FALSE 0.01   <NA>
12     4    2    1           source  0.01 0.06 1 FALSE 0.05   base
13     5    1    1 .Rd_format_title  0.00 0.01 1 FALSE 0.01   <NA>
     level           g_id           t_id          f            
 Min.   : 1.0   Min.   :1.00   Min.   :1.0   Length:30         
 1st Qu.: 5.0   1st Qu.:1.00   1st Qu.:1.0   Class :character  
 Median : 7.0   Median :2.00   Median :1.0   Mode  :character  
 Mean   : 7.3   Mean   :1.90   Mean   :1.3                     
 3rd Qu.: 9.0   3rd Qu.:2.75   3rd Qu.:2.0                     
 Max.   :14.0   Max.   :4.00   Max.   :2.0                     
     start              end                n        leaf        
 Min.   :0.00000   Min.   :0.01000   Min.   :1   Mode :logical  
 1st Qu.:0.00000   1st Qu.:0.01250   1st Qu.:1   FALSE:25       
 Median :0.02000   Median :0.04000   Median :1   TRUE :5        
 Mean   :0.01667   Mean   :0.03533   Mean   :1                  
 3rd Qu.:0.03000   3rd Qu.:0.05500   3rd Qu.:1                  
 Max.   :0.04000   Max.   :0.06000   Max.   :1                  
      time            source         
 Min.   :0.01000   Length:30         
 1st Qu.:0.01000   Class :character  
 Median :0.01000   Mode  :character  
 Mean   :0.01867                     
 3rd Qu.:0.02000                     
 Max.   :0.06000                     

profr documentation built on May 2, 2019, 7:30 a.m.