From 4ad34423c6a0e25e293f60dbe9237fc7e5d69854 Mon Sep 17 00:00:00 2001 From: HannesOberreiter Date: Thu, 19 Aug 2021 10:12:35 +0200 Subject: [PATCH] Update 23_Measuring_performance.Rmd --- 23_Measuring_performance.Rmd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/23_Measuring_performance.Rmd b/23_Measuring_performance.Rmd index d2e653b7..16bf1a89 100755 --- a/23_Measuring_performance.Rmd +++ b/23_Measuring_performance.Rmd @@ -70,11 +70,17 @@ f2 <- function(n = 1e5) { profvis::profvis(f2(), torture = TRUE) ``` -Unfortunately, this still takes too long, and we are literally stuck in profiling. +Unfortunately, this still takes too long, and we are literally stuck in profiling. If we set `torture = FALSE` or `torture = 0` the function is too fast for profiling. To workaround this problem, we can use a higher step integer for torture, for example set `torture = 10`. This will still take some time but is already a lot quicker. -Anecdotally, one of the authors once finished the profiling under an older R version. But the output seemed to be not very meaningful. +```{r,eval = FALSE} +f2 <- function(n = 1e5) { + x <- rep(1, n) + rm(list = "x") +} +profvis::profvis(f2(), torture = 10) +``` -In conclusion, this question appears to be unanswerable for us, even for Hadley. +The output does not seem meaningful, as we can see that the garbage collector takes a lot of turns. Though, the `torture` flag do allow us to profile a function, which otherwise would be too fast for profiling. ## Microbenchmarking