执行 Rprof() 后清空输出文件

Empty output file after executing Rprof()

最近,我了解到Rprof()这个功能。我尝试了 运行 各种示例,但其中 none 似乎有效。下面我给你一个:

R 中的脚本 I 运行:

# Turn on the profiler. By default it will write its output
# to a file called Rprof.out in my R directory
Rprof()

# code to be profiled
y <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
x <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
lm(y ~ x)

# Turn off the profiler
Rprof(NULL)

# getting a summary of the output
summaryRprof()
$by.self
[1] self.time  self.pct   total.time total.pct 
<0 rows> (or 0-length row.names)

$by.total
[1] total.time total.pct  self.time  self.pct  
<0 rows> (or 0-length row.names)

$sample.interval
[1] 0.02

$sampling.time
[1] 0

此外,当我在r中打开Rprof.out文件时,它只有一行如下:

sample.interval=20000

对于我做错的任何帮助,我将不胜感激,因为我期望的输出不应该是 0 行,但应该有 lm、lmfit 和所有lm 调用堆栈中的其他函数。

我正在使用 Rx64 3.3.1(通过 R studio),我的 OS 是 Windows 10 64 位。

您的代码运行时间少于采样间隔(20 毫秒),因此没有结果。