profileCallGraph2Dot: Write Call Graph for Rprof Profile Data to Graphviz Dot File

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

View source: R/proftools.R

Description

Prints a Graphviz .dot file representation of the call graph for profile data produced by Rprof.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
profileCallGraph2Dot(pd, score = c("none", "total", "self"),
                     transfer = function(x) x, nodeColorMap = NULL,
                     edgeColorMap = NULL, filename = "Rprof.dot",
                     landscape = FALSE, mergeCycles = FALSE,
                     edgesColored = FALSE,
                     rankDir = c("TB", "LR"),
                     nodeDetails = FALSE, edgeDetails = FALSE,
                     nodeSizeScore = c("none", "total", "self"),
                     edgeSizeScore = c("none", "total"),
                     center = FALSE, size, shape = "ellipse",
                     layout = "dot", style, GC = TRUE,
                     maxnodes = NA, total.pct = 0)

Arguments

pd

profile data as returned by readProfileData.

score

character string specifying whether to use total time or self time for coloring nodes/edges; no color used if missing.

transfer

function; maps score values in unit interval to unit interval

nodeColorMap,edgeColorMap

character vectors of color specifications as produced by rainbow; transfer of score is mapped to color

filename

name of .dot file

landscape

logical; whether to add the rotate=90 option to the .dot file

mergeCycles

logical; whether to merge each cycle of recursion into a single node

edgesColored

logical; whether to color edges

rankDir

character; value to use for the rankdir= option to specify the direction that the plot is laid out using the dot layout; must be either "TB" for Top-to-Bottom or "LR" for Left-to-Right. The default value is "LR".

nodeDetails,edgeDetails

logical; whether count information should be shown.

nodeSizeScore

character; value to encode in the size of the nodes.

edgeSizeScore

character; value to encode in the width of the edges.

center

logical; whether to add the center=1 option to the .dot file.

size

character; string to add as size= option in the .dot file.

shape

character; node shape.

layout

character; layout method to use.

style

named list of values for arguments score through layout to use if not explicitly supplied.

GC

logical; include GC information or not.

maxnodes

integer; maximal number of nodes to use; nodes with lower total hit counts are dropped.

total.pct

numeric; if positive, nodes with hit percentages below this level are dropped.

Details

Writes the call graph as a Graphviz .dot file. Color is used to encode the fraction total or self time spent in each function or call. The scores used correspond to the values in the printed representation produced by printProfileCallGraph. For now, see the gprof manual for further details. The color encoding for a score s and a color map m is ceiling(length(m) * transfer(s))

A style can be specified to set options to a set of cvalues that work well together.

Value

Used for side effect.

Note

Because of lazy evaluation, nested calls like f(g(x)) appear in the profile graph as f or one of its callees calling g.

Calls to functions with names containing a | character are dropped as they cause problems in the graph package.

Author(s)

Luke Tierney

References

User manual for gprof, the GNU profiler.

Graphviz: https://graphviz.gitlab.io/download/

See Also

Rprof, summaryRprof, readProfileData, flatProfile, plotProfileCallGraph, printProfileCallGraph plain.style google.style

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
pd <- readProfileData(system.file("samples", "glmEx.out", package="proftools"))
tmp <- tempfile()
profileCallGraph2Dot(pd, filename = tmp)
file.show(tmp)
unlink(tmp)

## Not run: 
## If you have graphviz installed on a UNIX-like system
## then in R do:

tmp.dot <- tempfile()
tmp.pdf <- tempfile()

profileCallGraph2Dot(pd, filename = tmp.dot)
system(sprintf("dot -Tpdf -o
browseURL(sprintf("file://

profileCallGraph2Dot(pd, filename = tmp.dot)
system(sprintf("dot -Tpdf -o
browseURL(sprintf("file://

unlink(tmp.dot)
unlink(tmp.pdf)
  
## End(Not run)

proftools documentation built on July 8, 2020, 5:20 p.m.