Description Usage Arguments Details Value Author(s) See Also Examples
Create 'aprof' objects for usage with 'aprof' functions
1 |
src |
The name of the source code file (and path if not in the working
directory). The source code file is expected to be a
a plain text file (e.g. txt, .R), containing the code of the
previously profiled program. If left empty, some "aprof" functions
(e.g. |
output |
The file name (and path if not in the working directory) of a previously created profiling exercise. |
Creates an "aprof" object from the R-profiler's output and a source file.
The objects created through "aprof" can be used by the standard functions
plot, summary and print (more specifically:
plot.aprof
, summary.aprof
and print.arof
).
See the example below for more details.
Using aprof with knitr and within .Rmd or .Rnw documents is not yet supported by the R profiler. Note that setting the chuck option: engine="Rscript", disables line-profiling. Line profiling only works in a interactive session (Oct 2015). In these cases users are advised to use the standard Rprof functions or "profr" (while setting engine="Rscript") and not to rely on line-profiling based packages (for the time being).
An aprof object
Marco D. Visser
plot.aprof
, summary.aprof
,
print.aprof
, Rprof
and
summaryRprof
.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ## 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)
## display basic information, summarize and plot the object
fooaprof
summary(fooaprof)
plot(fooaprof)
profileplot(fooaprof)
## To continue with memory profiling:
## enable memory.profiling=TRUE
Rprof(tmp,line.profiling=TRUE,memory.profiling=TRUE)
foo(1e4)
Rprof(append=FALSE)
## Create a aprof object
fooaprof<-aprof("foo.R",tmp)
## display basic information, and plot memory usage
fooaprof
plot(fooaprof)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.