2011-12-09 7 views
5

system.timeに似た関数を使って、一度に複数の関数の時間を評価し、1つの出力を吐き出すということを見ました。私はそれが何だったのか覚えていないし、私が使っている用語でインターネット検索をしても、私が望む応答が得られない。system.timeに代わる多機能テスター

誰かが私が話している機能の名前/場所を知っていますか?

答えて

9

rbenchmarkパッケージとそのbenchmark機能が必要です。

R> example(benchmark) 

bnchmrR> # example 1 
bnchmrR> # benchmark the allocation of one 10^6-element numeric vector, 
bnchmrR> # replicated 100 times 
bnchmrR> benchmark(1:10^6) 
    test replications elapsed relative user.self sys.self user.child sys.child 
1 1:10^6   100 0.286  1  0.2  0.08   0   0 

bnchmrR> # Example 2 
bnchmrR> # A call to benchmark with two named expressions and three replication 
bnchmrR> # counts, output sorted by the replication counts and then by the 
bnchmrR> # elapsed time: 
bnchmrR> means.rep = function(n, m) 
bnchmr+ mean(replicate(n, rnorm(m))) 

bnchmrR> means.pat = function(n, m) 
bnchmr+ colMeans(array(rnorm(n*m), c(m, n))) 

bnchmrR> benchmark(
bnchmr+ rep=means.rep(100, 100), 
bnchmr+ pat=means.pat(100, 100), 
bnchmr+ replications=10^(1:3), 
bnchmr+ order=c('replications', 'elapsed')) 
    test replications elapsed relative user.self sys.self user.child sys.child 
4 pat   10 0.011 1.00000  0.02  0   0   0 
1 rep   10 0.015 1.36364  0.02  0   0   0 
5 pat   100 0.107 9.72727  0.10  0   0   0 
2 rep   100 0.155 14.09091  0.16  0   0   0 
6 pat   1000 1.073 97.54545  1.07  0   0   0 
3 rep   1000 1.553 141.18182  1.55  0   0   0 
+0

それだ:ここで(。関連して、より専門的なmicrobenchmarkパッケージもあります)

は、例のセクションの始まりです。ダークに感謝します。 –

関連する問題