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.006        0   0.006
#> 2     build     0.032        0   0.032
#> 3    render     0.036        0   0.036
#> 4      draw     0.018        0   0.017
#> 5     TOTAL     0.092        0   0.091
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
#>        step user.self sys.self elapsed
#> 1 construct     0.004        0   0.005
#> 2     build     0.024        0   0.024
#> 3    render     0.080        0   0.080
#> 4      draw     0.028        0   0.028
#> 5     TOTAL     0.136        0   0.137

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

#>        step user.self sys.self elapsed
#> 1 construct     0.004        0   0.004
#> 2     build     0.023        0   0.023
#> 3    render     0.039        0   0.039
#> 4      draw     0.016        0   0.015
#> 5     TOTAL     0.082        0   0.081