readRprof: Read 'Rprof' Output files and Stack Logs

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/readRprof.R

Description

Read a log of stack entries, such as the output of the Rprof function, and generate a more accessible representation.

Usage

1
2
3
4
readRprof(filename = "Rprof.out", chunksize = 5000,
	interval = 0.02, 
	head = c("auto", "none", "Rprofmem"),
	 id = NULL)

Arguments

filename

Name of a file produced by Rprof().

chunksize

Number of lines to read at a time.

interval

Real number: time interval between samples, in s. Defaults to 0.02s for consistency with Rprof, but shorter times should be used.

head

c("auto", "none", "Rprofmem") to interpret control information as provided by Rprof or Rprofmem. See details.

id

An optional identification string. Defaults to filename and date.

Details

This function reads a log file of stacks, one stack snapshot per line, stack entries separated by space.

As profiling output file could be very large, it is read in blocks of chunksize lines. Increasing chunksize will make the function run faster if sufficient memory is available.

(This data structure is subject to change.)

The input format is controlled by the head argument. Format "auto" tries to detect control lines as interspersed by Rprof. These lines are not included in the output.

"none" ignores all control information and includes these lines as strange stacks.

"Rprofmem" isolates headers as provided by Rprofmem. "Rprofmem" new page entries are encoded as malloc requests with length 0.

Value

This data structure is subject to change.

Temporarily: A list with components

info

Summary information.

nodes

A vector of node names. This may include stray entries from interspersed lines.

stacks

Stacks, represented as reference list to nodes, and stack frequencies.

profiles

Recorded data, as reference to stacks, and possibly additional data per reference.

nodes is (conceptually) a data frame with entries

name node name
self.time nr of events with node as terminal leaf
self.time proportion of self.time with node as terminal leaf
total.time nr of events with node in stack
self.time proportion of total time with node as terminal leaf
nr.runs number of runs, over all run lengths and levels
nr.runs average of run length, over all run lengths and levels
icol current colour index

Author(s)

Günther Sawitzki <gsawitzki@users.r-forge.r-project.org>, based on the code of summaryRprof

References

http://sintro.r-forge.r-project.org/

See Also

summaryRprof

summaryRprof

flatProfile in library(proftools).

parse_rprof in library(profr).

The chapter on “Tidying and profiling R code” in “Writing R Extensions” (see the ‘doc/manual’ subdirectory of the R source tree).

Rprof is a sampling profiler.

tracemem traces copying of an object via the C function duplicate.

Rprofmem is a non-sampling memory-use profiler.

http://developer.r-project.org/memory-profiling.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
## Rprof() is not available on all platforms
profinterval <- 0.001
simruns <- 100

n <- 10000
x <- runif(n)
y0 <- 2+ 3 * x

sinknull <- textConnection(NULL, "w"); sink(sinknull)
Rprof(tmp <- tempfile(), interval = profinterval)
for (i in 1:simruns) {y <- y0 +  rnorm(n); xxx<- summary(lm(y~x))}
Rprof()

Rprof_out <- readRprof(tmp)

unlink(tmp)
sink(); close(sinknull)

str(Rprof_out)

## End(Not run)

sprof documentation built on May 2, 2019, 4:45 p.m.