测量功能执行时间R中是否有标准化的方式?R中测量功能执行时间
显然我可以在执行前后采取system.time
,然后拿这些差别,但我想知道是否有一些标准化的方式或功能(想不发明轮子)。
我似乎记得我曾经用过的东西象下面这样:
somesysfunction("myfunction(with,arguments)")
> Start time : 2001-01-01 00:00:00 # output of somesysfunction
> "Result" "of" "myfunction" # output of myfunction
> End time : 2001-01-01 00:00:10 # output of somesysfunction
> Total Execution time : 10 seconds # output of somesysfunction
我觉得你在脑子里有'proc.time',因为'system.time'是你需要的。 – Marek 2011-06-07 08:35:24
对于更大的功能,'Rprof'很好。它提供代码块/函数中所有进程的配置文件。 – 2014-08-24 17:08:24
新R用户通过谷歌发现这个问题:'require(microbenchmark)'现在(自几年前)社区标准的时间方式。 times < - microbenchmark(lm(y〜x),glm(y〜x),times = 1e3);例如(微基准)'。这对'lm'和'glm'进行1000次以上的统计比较,而不是'system.time'测试一次。 – isomorphismes 2015-04-24 17:42:38