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.004        0   0.004
#> 2     build     0.021        0   0.022
#> 3    render     0.033        0   0.033
#> 4      draw     0.015        0   0.015
#> 5     TOTAL     0.073        0   0.074
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.023        0   0.023
#> 3    render     0.076        0   0.076
#> 4      draw     0.027        0   0.027
#> 5     TOTAL     0.130        0   0.130

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

#>        step user.self sys.self elapsed
#> 1 construct     0.003    0.000   0.003
#> 2     build     0.020    0.000   0.021
#> 3    render     0.034    0.001   0.034
#> 4      draw     0.015    0.000   0.015
#> 5     TOTAL     0.072    0.001   0.073