Summarize bench::mark results.

# S3 method for bench_mark
summary(object, filter_gc = TRUE, relative = FALSE,
  ...)

Arguments

object

bench_mark object to summarize.

filter_gc

If TRUE filter iterations that contained at least one garbage collection before summarizing.

relative

If TRUE all summaries are computed relative to the minimum execution time rather than absolute time.

...

Additional arguments ignored.

Value

A tibble with the additional summary columns. The following summary columns are computed

  • min - bench_time The minimum execution time.

  • mean - bench_time The arithmetic mean of execution time

  • median - bench_time The sample median of execution time.

  • max - bench_time The maximum execution time.

  • mem_alloc - bench_bytes Total amount of memory allocated by running the expression.

  • itr/sec - integer The estimated number of executions performed per second.

  • n_itr - integer Total number of iterations after filtering garbage collections (if filter_gc == TRUE).

  • n_gc - integer Total number of garbage collections performed over all runs.

Details

If filter_gc == TRUE (the default) runs that contain a garbage collection will be removed before summarizing. This is most useful for fast expressions when the majority of runs do not contain a gc. Call summary(filter_gc = FALSE) if you would like to compute summaries with these times, such as expressions with lots of allocations when all or most runs contain a gc.

Examples

dat <- data.frame(x = runif(10000, 1, 1000), y=runif(10000, 1, 1000)) # `bench::mark()` implicitly calls summary() automatically results <- bench::mark( dat[dat$x > 500, ], dat[which(dat$x > 500), ], subset(dat, x > 500)) # However you can also do so explicitly to filter gc differently. summary(results, filter_gc = FALSE)
#> # A tibble: 3 x 14 #> expression min mean median max `itr/sec` mem_alloc n_gc n_itr #> <chr> <bch:> <bch:> <bch:> <bch:tm> <dbl> <bch:byt> <dbl> <int> #> 1 dat[dat$x > 50… 307µs 496µs 335µs 9.69ms 2017. 414KB 15 1009 #> 2 dat[which(dat$… 239µs 404µs 264µs 9.54ms 2474. 355KB 16 1239 #> 3 subset(dat, x … 383µs 808µs 427µs 115.25ms 1238. 532KB 10 619 #> # ... with 5 more variables: total_time <bch:tm>, result <list>, memory <list>, #> # time <list>, gc <list>
# Or output relative times summary(results, relative = TRUE)
#> # A tibble: 3 x 14 #> expression min mean median max `itr/sec` mem_alloc n_gc n_itr #> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 dat[dat$x > 500, ] 1.29 1.28 1.27 1.17 1.28 1.17 1.5 1.63 #> 2 dat[which(dat$x > 5… 1 1 1 1 1.63 1 1.6 2.01 #> 3 subset(dat, x > 500) 1.60 1.63 1.61 1.11 1 1.50 1 1 #> # ... with 5 more variables: total_time <dbl>, result <list>, memory <list>, #> # time <list>, gc <list>