tracker(RUnit)
tracker()所属R语言包:RUnit
Tracking the results of the inspect process.
跟踪检查过程的结果。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The current implementation uses the 'closure trick' to hide all details from the user and only allows to retrieve the results of the code inspection. tracker is used to create a new environment to manage and store the results of the tracking process. The inspect function requires such an environment with the name "track" (currently mandatory). The tracker records how often each and every function was called by inspect and summarizes the results of all calls. tracker$init initializes the tracker environment. tracker$getTrackInfo returns a list with the tracked results of the inspection process.
当前实现使用的“封闭把戏隐藏用户的所有细节,只允许检索结果的代码检查。 tracker被用来创建一个新的环境管理和存储的跟踪过程的结果。 inspect功能需要这样的环境中的名称为“轨道”(目前是强制性的)。跟踪器的记录通常每个函数被称为inspect和总结的结果,所有的呼叫。 tracker$init初始化跟踪环境。 tracker$getTrackInfo返回一个列表的检查过程中的跟踪结果。
用法----------Usage----------
Details
详细信息----------Details----------
The 'trackInfo' S3 class object (list) has one entry for each function on the inspect list with the following elements:
trackInfo“S3类对象(list)对每个功能都有一个条目,检查列表包含下列元素:
srcThe source code of the function.
srcThe源代码的功能。
runThe number of executions for each line of code.
的重号的每一行代码的执行。
graphA matrix. Each element in the matrix counts how often a code line was called from the previous code line in the execution flow.
graphA矩阵。矩阵中的每个元素的计算往往是一个代码行被称为从以前的代码行的执行流程。
nrRunsCounts how often the function was called.
nrRunsCounts频率的函数被调用。
funcCallThe declaration of the function.
funcCallThe的函数声明。
方法----------Methods----------
init
init
addFunc
addFunc
getSource
getSource
bp
bp
getTrackInfo
getTrackInfo
isValid
isValid
(作者)----------Author(s)----------
Thomas K枚nig, Klaus J眉nemann
& Matthias Burger
参见----------See Also----------
inspect for the registration of functions \& methods to be on the tracking list, and printHTML.trackInfo for displaying results
inspect登记功能\&方法来跟踪,printHTML.trackInfo显示结果
实例----------Examples----------
## example functions[#示例函数]
foo <- function(x){
y <- 0
for(i in 1:100)
{
y <- y + i
}
return(y)
}
bar <- function(x){
y <- 0
for(i in 1:100)
{
y <- y - i
}
return(y)
}
## the object name track is 'fixed' (current implementation)[#对象名称的轨道是“固定”(目前的实现)]
track <- tracker()
## initialize the tracker[#初始化跟踪]
track$init()
## inspect the function[#检查功能]
## resFoo1 will contain the result of calling foo(50)[#resFoo1将包含调用foo(50)]
resFoo1 <- inspect(foo(50), track = track)
resFoo2 <- inspect(foo(20), track = track)
resBar1 <- inspect(bar(30), track = track)
## get the tracked function call info for all inspect calls[#获得跟踪函数调用的信息,所有检查调用]
resTrack <- track$getTrackInfo()
## create HTML sites in folder ./results for all inspect calls[#创建一个HTML文件夹中。网站的所有检查调用/结果]
printHTML.trackInfo(resTrack)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|