print.benchmark: Print method for the 'benchmark' timings.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/print.R

Description

This is universal method of measurement results representation, which can be called either implicitly or explicitly. The method uses summary method to compute aggregated statistics for benchmarking results. print also provides additional information about the timer precision and overhead, the execution regime and the number of repeats.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'benchmark'
print(
  x,
  units = "auto",
  order = "none",
  relative = "median",
  details = FALSE,
  ...
)

## S3 method for class 'summaryBenchmark'
print(x, units = "auto", order = "none", ...)

Arguments

x

An object of class benchmark, summaryBenchmark or meanBenchmark.

units

Character. The units to be used in printing the timings. The available units are nanoseconds ("ns"), microseconds ("us"), milliseconds ("ms"), seconds ("s").

order

Character. Order results according to this column of the output.

relative

Character. The name or index of the column whose values will be used to compute relative timings.

details

Logical. Show additional detauls about measurement process.

...

Arguments passed on to print.data.frame().

Value

Apart from the table output produced by summary, the method also prints additional information about the benchmarking process (with details = TRUE):

Timer precision

Timer precision in seconds.

Timer error

Timer error (overhead) in seconds.

Replications

Number of repeats for each expression.

Expressions order

Execution regime.

Garbage collection

Whether garbage collection took place before each execution.

Author(s)

Artem Klevtsov a.a.klevtsov@gmail.com

See Also

summary.benchmark(), mean.benchmark()

Examples

1
2
3
4
5
6
7
8
a1 <- a2 <- a3 <- a4 <- numeric(0)
res <- benchmark(
  a1 <- c(a1, 1),
  a2 <- append(a2, 1),
  a3[length(a3) + 1] <- 1,
  a4[[length(a4) + 1]] <- 1
)
print(res)

Example output

0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Benchmark summary:
Time units : nanoseconds 
                      expr n.eval  min lw.qu median mean up.qu   max  total
            a1 <- c(a1, 1)    100  409   833    968 1120  1180  3910 112000
       a2 <- append(a2, 1)    100 1250  1830   2090 2450  2400 12900 245000
   a3[length(a3) + 1] <- 1    100  959  1200   1490 1800  1890 13800 180000
 a4[[length(a4) + 1]] <- 1    100  900  1130   1490 1670  1810  5400 167000
 relative
     1.00
     2.16
     1.54
     1.54

benchr documentation built on March 13, 2020, 3:29 a.m.