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

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.003        0   0.003
#> 2     build     0.013        0   0.013
#> 3    render     0.020        0   0.019
#> 4      draw     0.028        0   0.028
#> 5     TOTAL     0.064        0   0.063
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.027        0   0.027
#> 3    render     0.055        0   0.054
#> 4      draw     0.047        0   0.047
#> 5     TOTAL     0.132        0   0.131

# 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.002
#> 2     build     0.013        0   0.013
#> 3    render     0.020        0   0.020
#> 4      draw     0.028        0   0.028
#> 5     TOTAL     0.063        0   0.063