作者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://webptt.com/cn.aspx?n=bbs/R_Language/M.1477287280.A.392.html
1F:→ celestialgod: Hadley XDD 你果然不想尊重他为大神XDD 10/24 13:38
2F:→ Edster: ps, 执行的时候会让人觉得很像当机. 那就是正在执行. 10/24 13:38
※ 编辑: Edster (140.112.64.48), 10/24/2016 13:38:57
3F:→ celestialgod: 後来lineprof已经废弃,改用profvis了 10/24 13:39
5F:→ Edster: typeof 难免, 先对大神说抱歉. 10/24 13:40
6F:→ celestialgod: typo? 10/24 13:41
7F:→ Edster: profvis 看起来更华丽,而且看来有"层"的概念,来用用。 10/24 13:42
8F:→ celestialgod: 左边expr下面是执行的命令,下面会列出里面各层的 10/24 13:42
9F:→ celestialgod: 程式码,感觉应该符合你的需求 10/24 13:42