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.002        0   0.003
#> 2     build     0.018        0   0.018
#> 3    render     0.018        0   0.018
#> 4      draw     0.020        0   0.020
#> 5     TOTAL     0.058        0   0.059
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
#>        step user.self sys.self elapsed
#> 1 construct     0.003        0   0.002
#> 2     build     0.037        0   0.036
#> 3    render     0.056        0   0.055
#> 4      draw     0.034        0   0.034
#> 5     TOTAL     0.130        0   0.127

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

#>        step user.self sys.self elapsed
#> 1 construct     0.002        0   0.003
#> 2     build     0.018        0   0.018
#> 3    render     0.018        0   0.017
#> 4      draw     0.020        0   0.020
#> 5     TOTAL     0.058        0   0.058