Skip to contents

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.006        0   0.006
#> 2     build     0.027        0   0.028
#> 3    render     0.042        0   0.041
#> 4      draw     0.018        0   0.019
#> 5     TOTAL     0.093        0   0.094
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
#>        step user.self sys.self elapsed
#> 1 construct     0.006        0   0.007
#> 2     build     0.029        0   0.028
#> 3    render     0.096        0   0.096
#> 4      draw     0.033        0   0.032
#> 5     TOTAL     0.164        0   0.163

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

#>        step user.self sys.self elapsed
#> 1 construct     0.005        0   0.005
#> 2     build     0.028        0   0.028
#> 3    render     0.041        0   0.041
#> 4      draw     0.018        0   0.018
#> 5     TOTAL     0.092        0   0.092