autoplot.bench_mark: Autoplot method for bench_mark objects

Description Usage Arguments Details Examples

View source: R/autoplot.R

Description

Autoplot method for bench_mark objects

Usage

1
2
3
4
5
6
7
8
autoplot.bench_mark(
  object,
  type = c("beeswarm", "jitter", "ridge", "boxplot", "violin"),
  ...
)

## S3 method for class 'bench_mark'
plot(x, ..., type = c("beeswarm", "jitter", "ridge", "boxplot", "violin"), y)

Arguments

object

A bench_mark object.

type

The type of plot. Plotting geoms used for each type are

  • beeswarm - ggbeeswarm::geom_quasirandom()

  • jitter - ggplot2::geom_jitter()

  • ridge - ggridges::geom_density_ridges()

  • boxplot - ggplot2::geom_boxplot()

  • violin - ggplot2::geom_violin()

...

Additional arguments passed to the plotting geom.

x

A bench_mark object.

y

Ignored, required for compatibility with the plot() generic.

Details

This function requires some optional dependencies. ggplot2, tidyr, and depending on the plot type ggbeeswarm, ggridges.

For type of beeswarm and jitter the points are colored by the highest level garbage collection performed during each iteration.

For plots with 2 parameters ggplot2::facet_grid() is used to construct a 2d facet. For other numbers of parameters ggplot2::facet_wrap() is used instead.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
dat <- data.frame(x = runif(10000, 1, 1000), y=runif(10000, 1, 1000))

res <- bench::mark(
  dat[dat$x > 500, ],
  dat[which(dat$x > 500), ],
  subset(dat, x > 500))

if (require(ggplot2) && require(tidyr)) {

  # Beeswarm plot
  autoplot(res)

  # ridge (joyplot)
  autoplot(res, "ridge")

  # If you want to have the plots ordered by execution time you can do so by
  # ordering factor levels in the expressions.
  if (require(dplyr) && require(forcats)) {

    res %>%
      mutate(expression = forcats::fct_reorder(as.character(expression), min, .desc = TRUE)) %>%
      as_bench_mark() %>%
      autoplot("violin")
  }
}

bench documentation built on March 26, 2020, 6:32 p.m.