plot: plot.aprof

Description Usage Arguments Author(s) Examples

Description

Plot execution time, or total MB usage when memory profiling, per line of code from a previously profiled source file. The plot visually shows bottlenecks in a program's execution time, shown directly next to the code of the source file.

Usage

1
2
## S3 method for class 'aprof'
plot(x, y, ...)

Arguments

x

An aprof object as returned by aprof(). If this object contains both memory and time profiling information both will be plotted (as proportions of total time and total memory allocations.

y

Unused and ignored at current.

...

Additional printing arguments. Unused at current.

Author(s)

Marco D. Visser

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)
plot(fooaprof)

## End(Not run)

Example output

Warning messages:
1: In readLineDensity(aprofobject, Memprof = AddMemProf) :
  specified source
      file foo.R is not in the list of files in the
      profiler output: 
 
2: In readLineDensity(aprofobject, Memprof = AddMemProf) :
  Some aprof functions may fail --> user supplied source filefoo.R does not seem to correspond to any file in the profiler output.
 Possible causes: 
1) Source file was not profiled?
2) Spelling?

aprof documentation built on May 2, 2019, 6:11 a.m.

Related to plot in aprof...