aprofFun: Light wrapper around the aprof function to profile one...

Description Usage Arguments Value Examples

Description

Light wrapper around the aprof function to profile one function

Usage

1
aprofFun(expr, FUN)

Arguments

expr

Expression to profile

FUN

The name of the function to profile, as a string (e.g. "f")

Value

An aprof object

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
# The function to profile
f = function(n, sim) {
  # Simulate some data
  x = rnorm(n, mean = 0, sd = 2)
  t = data.frame(x)
  for (i in 1:sim) {
   y = x + rnorm(x, mean = 0, sd = 0.5)
    t = cbind(t, y)
  }
  return(t)
}

# Another function calling f
g = function(x) {
  print(x + x)
  output = f(100, 100)
  return(output)
}

# Profiling:
## f is run
prof = aprofFun(f(100, 100), "f")
viewProfHtml(prof)
## g is run, profiling either "g" or "f"
prof = aprofFun(g(10), "g")
viewProfHtml(prof)
prof = aprofFun(g(10), "f")
viewProfHtml(prof)

mdjbru-R-packages/aprofW documentation built on May 22, 2019, 3:37 p.m.