profileplot: Line progression plot

Description Usage Arguments Details Author(s) See Also Examples

View source: R/aprof.R

Description

A profile plot describing the progression through each code line during the execution of the program.

Usage

1
profileplot(aprofobject)

Arguments

aprofobject

An aprof object returned by the function aprof

Details

Given that a source code file was specified in an "aprof" object this function will estimate when each lines was executed. It identifies the largest bottleneck and indicates this on the plot with red markings (y-axis). R uses a statistical profiler which, using system interrupts, temporarily stops execution of a program at fixed intervals. This is a profiling technique that results in samples of "the call stack" every time the system was stopped. The function profileplot uses these samples to reconstruct the progression through the program. Note that the best results are obtained when a decent amount of samples have been taken (relative to the length of the source code). Use print.aprof to see how many samples (termed "Calls") of the call stack were taken.

Author(s)

Marco D. Visser

See Also

plot.aprof

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
# create function to profile
     foo <- function(N){
             preallocate<-numeric(N)
             grow<-NULL
              for(i in 1:N){
                  preallocate[i]<-N/(i+1)
                  grow<-c(grow,N/(i+1))
                 }
     }

     #save function to a source file and reload
     dump("foo",file="foo.R")
     source("foo.R")

     # create file to save profiler output
     tmp<-tempfile()

     # Profile the function
     Rprof(tmp,line.profiling=TRUE)
     foo(1e4)
     Rprof(append=FALSE)

     # Create a aprof object
     fooaprof<-aprof("foo.R",tmp)
     profileplot(fooaprof)

## End(Not run)


aprof documentation built on May 19, 2017, 10:02 a.m.
Search within the aprof package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.