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.004
#> 2     build     0.027        0   0.027
#> 3    render     0.032        0   0.033
#> 4      draw     0.039        0   0.039
#> 5     TOTAL     0.102        0   0.103
benchplot(ggplot(mtcars, aes(mpg, wt)) + geom_point() + facet_grid(. ~ cyl))
#>        step user.self sys.self elapsed
#> 1 construct     0.004        0   0.004
#> 2     build     0.050        0   0.050
#> 3    render     0.090        0   0.090
#> 4      draw     0.066        0   0.066
#> 5     TOTAL     0.210        0   0.210

# 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.026        0   0.026
#> 3    render     0.036        0   0.036
#> 4      draw     0.036        0   0.036
#> 5     TOTAL     0.102        0   0.102