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:
testmeans expression (R code) to be evaluated.replicationsmeans the number of replications used within each individual benchmark.elapsedmeans the total elapsed times for the currently running R processuser.selfmeans ‘user.time’, which is the CPU time charged for the execution of user instructions of the calling process.sys.seltmean ‘system.time’, which is the CPU time charged for execution by the system on behalf of the calling process.user.childandsys.childare not available on Windows and will always be given as NA.relativemeans 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
rbindlistis the fastest way
本文深入解析R编程中性能评估工具Benchmark包,包括其核心功能、参数使用及返回结果解释,帮助读者掌握如何有效利用Benchmark进行R代码性能比较。
353

被折叠的 条评论
为什么被折叠?



