我开始了解这个microbenchmark
R
包的一些功能。我从 Hadley Wickham 的这个出版物中实现了一个示例代码,并收到一个错误,我找不到任何准确的信息,我无法处理。提前感谢您的任何解释/提示等。
示例代码:
library(microbenchmark)
f <- function() NULL
microbenchmark(
NULL,
f()
)
控制台输出:
Error in microbenchmark(NULL, f()) :
Measured negative execution time! Please investigate and/or contact the package author.
更新。这是我的seesionInfo()
控制台输出:
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Polish_Poland.1250 LC_CTYPE=Polish_Poland.1250 LC_MONETARY=Polish_Poland.1250
[4] LC_NUMERIC=C LC_TIME=Polish_Poland.1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.3.1 microbenchmark_1.3-0
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.3 grid_3.0.2 gtable_0.1.2 labeling_0.2
[7] MASS_7.3-29 munsell_0.4.2 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2
[13] scales_0.2.3 stringr_0.6.2 tools_3.0.2
更新 2.包的作者要求我提供一些进一步的信息:
R 变量
R.version
R.version _
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 0.2
year 2013
month 09
day 25
svn rev 63987
language R
version.string R version 3.0.2 (2013-09-25) 昵称飞盘帆船我电脑中 CPU 的品牌、型号和速度:
处理器:Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz 3.70 GHz
内存:16,0 GB
系统类型:64位
更新 3。
我注意到上面代码的修改之一确实返回了正确的结果:
> ### 1
> f <- function(){NULL}
> microbenchmark(NULL, f())
Error in microbenchmark(NULL, f()) :
Measured negative execution time! Please investigate and/or contact the package author.
>
>
> ### 2
> f <- function(){ }
> microbenchmark(NULL, f())
Error in microbenchmark(NULL, f()) :
Measured negative execution time! Please investigate and/or contact the package author.
>
>
> ### 3
> f <- function(){NULL}
> microbenchmark(f())
Unit: nanoseconds
expr min lq median uq max neval
f() 0 1 1 1 7245 100
>
> ### 4
> f <- function(){ }
> microbenchmark(f())
Error in microbenchmark(f()) :
Measured negative execution time! Please investigate and/or contact the package author.