TMB (version 1.7.15)

benchmark: Benchmark parallel templates

Description

Benchmark parallel templates

Plot result of parallel benchmark

Usage

benchmark(obj, n = 10, expr = NULL, cores = NULL)

# S3 method for parallelBenchmark plot(x, type = "b", ..., show = c("speedup", "time"), legendpos = "topleft")

Arguments

obj

Object from MakeADFun

n

Number of replicates to obtain reliable results.

expr

Optional expression to benchmark instead of default.

cores

Optional vector of cores.

x

Object to plot

type

Plot type

...

Further plot arguments

show

Plot relative speedup or relative time?

legendpos

Position of legend

Details

By default this function will perform timings of the most critical parts of an AD model, specifically

  1. Objective function of evaluated template.

  2. Gradient of evaluated template.

  3. Sparse hessian of evaluated template.

  4. Cholesky factorization of sparse hessian.

(for pure fixed effect models only the first two). Expressions to time can be overwritten by the user (expr). A plot method is available for Parallel benchmarks.

Examples

Run this code
# NOT RUN {
runExample("linreg_parallel",thisR=TRUE)  ## Create obj
ben <- benchmark(obj,n=100,cores=1:4)
plot(ben)
ben <- benchmark(obj,n=10,cores=1:4,expr=expression(do.call("optim",obj)))
plot(ben)
# }

Run the code above in your browser using DataLab