作者Edster (Edster)
看板R_Language
標題[問題] lineprfo 可否決定層數?
時間Mon Oct 24 13:34:31 2016
最近要檢查一支程式為何越來越慢 (因為陸陸續續修改,有陸續加東西)
我用 hadley 大神寫的 lineprof pkg 來確認。
可參考
http://adv-r.had.co.nz/Profiling.html
https://github.com/hadley/lineprof
想偷懶看中文也是有 (我是英文看完才發現有中文)
http://blog.fens.me/r-perform-lineprof/
雖然看的到function中"每支" function 的執行時間,
但是我想知道的是某層 function 的總執行時間,
他的資料結構我也不太容易輸出成 csv 自己加
因此想請問有經驗的板友
我可否在設定上使用 lineprof 來計算某層function的總執行時間?
或是用什麼方式輸出成檔案自己加?
感謝先。
ps:
如果想要裝的話,要從GitHub自己下載source自己轉成binary
以下是我的安裝過程,後面附的是官方範例。
devtools或是Rcpp可能要先刪掉重新裝。
==
install.packages("devtools")
install.packages("Rcpp")
library(devtools)
devtools::install_github("hadley/lineprof")
install_github("wch/shiny-slickgrid",force=TRUE)
library(lineprof)
library(shiny)
source(find_ex("read-delim.r"))
source(find_ex("read-table.r")) # local copy so get line numbers
wine <- find_ex("wine.csv")
## Not run:
y1 = read.table2(wine, sep = ",")
system.time(x1 <- lineprof(read.table2(wine, sep = ","), torture = TRUE))
x2 <- lineprof(read_delim(wine), torture = TRUE)
shine(x1)
shine(x2)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.64.48
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1477287280.A.392.html
→ celestialgod: Hadley XDD 你果然不想尊重他為大神XDD 10/24 13:38
→ Edster: ps, 執行的時候會讓人覺得很像當機. 那就是正在執行. 10/24 13:38
※ 編輯: Edster (140.112.64.48), 10/24/2016 13:38:57
→ celestialgod: 後來lineprof已經廢棄,改用profvis了 10/24 13:39
→ Edster: typeof 難免, 先對大神說抱歉. 10/24 13:40
→ celestialgod: typo? 10/24 13:41
→ Edster: profvis 看起來更華麗,而且看來有"層"的概念,來用用。 10/24 13:42
→ celestialgod: 左邊expr下面是執行的命令,下面會列出裡面各層的 10/24 13:42
→ celestialgod: 程式碼,感覺應該符合你的需求 10/24 13:42