Skip to content

Benchmark plot creation time. Broken down into construct, build, render and draw times.

Usage

benchplot(x)

Arguments

x

code to create ggplot2 plot

Examples

benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point())
#>        step user.self sys.self elapsed
#> 1 construct     0.004        0   0.003
#> 2     build     0.021        0   0.022
#> 3    render     0.022        0   0.022
#> 4      draw     0.019        0   0.019
#> 5     TOTAL     0.066        0   0.066
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
#>        step user.self sys.self elapsed
#> 1 construct     0.003        0   0.003
#> 2     build     0.024        0   0.023
#> 3    render     0.054        0   0.054
#> 4      draw     0.035        0   0.035
#> 5     TOTAL     0.116        0   0.115

# With tidy eval:
p <- expr(ggplot(mtcars, aes(mpg, wt)) + geom_point())
benchplot(!!p)

#>        step user.self sys.self elapsed
#> 1 construct     0.003    0.000   0.002
#> 2     build     0.019    0.001   0.021
#> 3    render     0.021    0.000   0.021
#> 4      draw     0.020    0.000   0.019
#> 5     TOTAL     0.063    0.001   0.063