Learn R Programming

aprof (version 0.3.2)

profileplot: Line progression plot

Description

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

Usage

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.

See Also

plot.aprof

Examples

Run this code
## 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)

Run the code above in your browser using DataLab