benchr

GitLab CI Build Status AppVeyror Build status Codecov Code Coverage License CRAN Status

Package benchr provides an infrastructure (framework) for precise measurement of R expressions execution time.

Key features:

Installation

To install the package from the CRAN run the following command:

install.packages("benchr", repos = "https://cloud.r-project.org/")

To install the development version from git repository the install_git() function from devtools package can be used:

devtools::install_git("https://gitlab.com/artemklevtsov/benchr")

This package contains the compiled code, so to install it on Windows you will also need Rtools.

Usage

To measure execution time of arbitrary R code, benchr provides function benchmark(), as well as a number of additional methods for analysis and representation of results. Here's an example of time measurement for several expressions.

library(benchr)
benchmark(rep(1:10, each = 10), rep.int(1:10, rep.int(10, 10)))
#> Benchmark summary:
#> Time units : microseconds
#>                            expr n.eval  min lw.qu median mean up.qu  max total relative
#>            rep(1:10, each = 10)    100 2.28  2.44   2.50 2.52  2.56 4.32   252     1.32
#>  rep.int(1:10, rep.int(10, 10))    100 1.63  1.80   1.89 1.92  1.99 4.34   192     1.00

The resulting object can be saved as a variable and reused later in further methods:

res <- benchmark(NULL, {NULL}, {{{NULL}}})
summary(res)
#> Time units : nanoseconds
#>              expr n.eval min lw.qu median  mean up.qu max total relative
#>              NULL    100   8    14     16  16.4    19  31  1640     1.00
#>          { NULL }    100  97   109    115 116.0   120 197 11600     7.19
#>  { { { NULL } } }    100 159   178    181 190.0   187 871 19000    11.30

To present the results of measurements implemented additional methods for the class benchmark object:

For further details refer to the manual pages and vignettes:

help(package = "benchr")

Bug reports

Use the following command to go to the page for bug report submissions:

bug.report(package = "benchr")

Before reporting a bug or submitting an issue, please do the following:

When submitting a bug report please include the output produced by functions traceback() and sessionInfo(). This may save a lot of time.

License

The benchr package is distributed under GPLv2 license.