Print microbenchmark timings.

# S3 method for class 'microbenchmark'
print(x, unit, order, signif, ...)

Arguments

x

An object of class microbenchmark.

unit

What unit to print the timings in. Default value taken from to option microbenchmark.unit (see example).

order

If present, order results according to this column of the output.

signif

If present, limit the number of significant digits shown.

...

Passed to print.data.frame

Note

The available units are nanoseconds ("ns"), microseconds ("us"), milliseconds ("ms"), seconds ("s") and evaluations per seconds ("eps") and relative runtime compared to the best median time ("relative").

If the multcomp package is available a statistical ranking is calculated and displayed in compact letter display from in the cld column.

See also

Author

Olaf Mersmann

Examples

a1 <- a2 <- a3 <- a4 <- numeric(0)

res <- microbenchmark(a1 <- c(a1, 1),
                      a2 <- append(a2, 1),
                      a3[length(a3) + 1] <- 1,
                      a4[[length(a4) + 1]] <- 1,
                      times=100L)
print(res)
#> Unit: nanoseconds
#>                       expr min     lq    mean median     uq   max neval cld
#>             a1 <- c(a1, 1) 326  459.5  584.23  519.5  621.0  2986   100 a  
#>        a2 <- append(a2, 1) 932 1116.0 1616.84 1361.5 1819.5 13820   100  b 
#>    a3[length(a3) + 1] <- 1 537  589.5 1231.85  880.5 1301.5 23461   100  bc
#>  a4[[length(a4) + 1]] <- 1 515  636.0 1017.73  979.0 1217.0  5193   100 a c
## Change default unit to relative runtime
options(microbenchmark.unit="relative")
print(res)
#> Unit: nanoseconds
#>                       expr min     lq    mean median     uq   max neval cld
#>             a1 <- c(a1, 1) 326  459.5  584.23  519.5  621.0  2986   100 a  
#>        a2 <- append(a2, 1) 932 1116.0 1616.84 1361.5 1819.5 13820   100  b 
#>    a3[length(a3) + 1] <- 1 537  589.5 1231.85  880.5 1301.5 23461   100  bc
#>  a4[[length(a4) + 1]] <- 1 515  636.0 1017.73  979.0 1217.0  5193   100 a c
## Change default unit to evaluations per second
options(microbenchmark.unit="eps")
print(res)
#> Unit: nanoseconds
#>                       expr min     lq    mean median     uq   max neval cld
#>             a1 <- c(a1, 1) 326  459.5  584.23  519.5  621.0  2986   100 a  
#>        a2 <- append(a2, 1) 932 1116.0 1616.84 1361.5 1819.5 13820   100  b 
#>    a3[length(a3) + 1] <- 1 537  589.5 1231.85  880.5 1301.5 23461   100  bc
#>  a4[[length(a4) + 1]] <- 1 515  636.0 1017.73  979.0 1217.0  5193   100 a c