18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rコードの実行時間を測るのに便利です「tictoc」パッケージ

Last updated at Posted at 2017-11-04

tictoc はRコードの実行時間の計測を簡単にするパッケージです。
使い方は tic()toc() でコードを挟んで実行するだけです。

インストール
install.packages("tictoc")
使い方
library(tictoc)

tic()
Sys.sleep(1)
toc()
結果
1.003 sec elapsed

ランダムフォレストの実行時間を比較してみる。

R
library(kernlab)
data(spam)

library(randomForest)
tic()
randomForest(type ~ ., data = spam, ntree = 1000)
toc()
#> 26.535 sec elapsed

library(ranger)
tic()
ranger(type ~ ., data = spam, num.trees = 1000, seed = 71)
toc()
#> 4.867 sec elapsed

tic()
ranger(type ~ ., data = spam, num.trees = 1000, seed = 71, save.memory = TRUE)
toc()
#> 10.808 sec elapsed

library(Rborist)
tic()
Rborist(spam[,-58], spam[,58], nTree = 1000)
toc()
#> 12.574 sec elapsed

参考

18
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?