Benchmark package consists of only one function benchmark
, which is a simple wrapper of system.time
to evaluate expression of R code.
Usage:
benchmark(...,columns = c("test", "replications", "elapsed", "relative", "user.self", "sys.self",
"user.child", "sys.child"), order = "test", replications = 100, environment = parent.frame(), relative = "elapsed")
It means evaluate expression
...
and return the results of c("test", "replications", "elapsed", "relative", "user.self", "sys.self",
. All column result can be choose which to return using column setting.
"user.child", "sys.child")
Now give the meaning of each column:
test
means expression (R code) to be evaluated.replications
means the number of replications used within each individual benchmark.elapsed
means the total elapsed times for the currently running R processuser.self
means ‘user.time’, which is the CPU time charged for the execution of user instructions of the calling process.sys.selt
mean ‘system.time’, which is the CPU time charged for execution by the system on behalf of the calling process.user.child
andsys.child
are not available on Windows and will always be given as NA.relative
means the relative value or time using of the evaluated expressions.
So the we can use elapsed
time to compare R processes, which can be seen relative
directly.
From the blog,
the result of benchmark
is
From the column relative
, we see that
rbindlist
is the fastest way