2013-04-15 45 views
2

如何計算R腳本的運行時間?等價的bash命令**時間**

我基本上想要一個相當於bash命令時間

+4

您正在查找的函數是'system.time()'。 – A5C1D2H2I1M1N2O1R2T1

+1

您可能還想在這裏嘗試搜索:在右上角的搜索欄中輸入'[r] time'會讓您的結果(帶有R標籤)很快導致'system.time()'。 –

回答

6

使用system.time,或看看microbenchmark包。

3

您還可以使用rbenchmark包中的benchmark函數。請參閱幫助文件here

0

如果它不能由system.time()評估一個複雜的腳本,請嘗試:

start_time = proc.time() 
<your script here> 
end_time = proc.time() 
print(end_time - start_time) 

顯然,你需要運行線1-3彼此接近越好。

有一些例子here