Description Usage Arguments Value See Also Examples
Benchmark a list of quoted expressions. Each expression will always run at least twice, once to measure the memory allocation and store results and one or more times to measure timing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 
... 
Expressions to benchmark, if named the 
min_time 
The minimum number of seconds to run each expression, set to

iterations 
If not 
min_iterations 
Each expression will be evaluated a minimum of 
max_iterations 
Each expression will be evaluated a maximum of 
check 
Check if results are consistent. If 
memory 
If 
filter_gc 
If 
relative 
If 
time_unit 
If 
exprs 
A list of quoted expressions. If supplied overrides expressions
defined in 
env 
The environment which to evaluate the expressions 
A tibble with the additional summary columns. The following summary columns are computed
expression
 bench_expr
The deparsed expression that was evaluated
(or its name if one was provided).
min
 bench_time
The minimum execution time.
median
 bench_time
The sample median of execution time.
itr/sec
 double
The estimated number of executions performed per
second.
mem_alloc
 bench_bytes
Total amount of memory allocated by R while
running the expression. Memory allocated outside the R heap, e.g. by
malloc()
or new
directly is not tracked, take care to avoid
misinterpreting the results if running code that may do this.
gc/sec
 double
The number of garbage collections per second.
n_itr
 integer
Total number of iterations after filtering
garbage collections (if filter_gc == TRUE
).
n_gc
 double
Total number of garbage collections performed over all
iterations. This is a psudomeasure of the pressure on the garbage collector, if
it varies greatly between to alternatives generally the one with fewer
collections will cause fewer allocation in real usage.
total_time
 bench_time
The total time to perform the benchmarks.
result
 list
A list column of the object(s) returned by the
evaluated expression(s).
memory
 list
A list column with results from Rprofmem()
.
time
 list
A list column of bench_time
vectors for each evaluated
expression.
gc
 list
A list column with tibbles containing the level of
garbage collection (02, columns) for each iteration (rows).
press()
to run benchmarks across a grid of parameters.
1 2 3 4 5 6 7  dat < data.frame(x = runif(100, 1, 1000), y=runif(10, 1, 1000))
mark(
min_time = .1,
dat[dat$x > 500, ],
dat[which(dat$x > 500), ],
subset(dat, x > 500))

# A tibble: 3 x 13
expression min median `itr/sec` mem_alloc `gc/sec` n_itr
<bch:expr> <bch:> <bch:> <dbl> <bch:byt> <dbl> <int>
1 dat[dat$x > 500, ] 32.7µs 36.7µs 21327. 136.64KB 21.7 1966
2 dat[which(dat$x > 500), ] 33.4µs 37.8µs 21038. 2.82KB 33.3 1896
3 subset(dat, x > 500) 59µs 66.3µs 12920. 24.12KB 21.4 1209
# … with 6 more variables: n_gc <dbl>, total_time <bch:tm>, result <list>,
# memory <list>, time <list>, gc <list>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.