0

I am trying to get some performance benchmarks for my code and have run both tictoc and prolifvis over the entire script.

The 'time elapsed' in seconds as shown by tictoc seems to give the absolute time elapsed when the code was run. However the time given in milliseconds by prolifvis is much shorter.

For example, tictoc tells me the time elapsed is 30.75secs but prolifvis shows only 410ms. This particular example is for scripts that produce plots with ggplot but other files that perform basic analyses on a dataframe show the same kind of difference

What exactly is prolifvis measuring?

tic() 
    df <- data.frame(var=c("a", "b", "c"), 
    nums=c(1:3))
    plot2 <- ggplot(df, aes(x=var, y=nums)) + 
    geom_bar(stat = "identity")
    print(plot2) 
toc()

profvis(expr = {
    df <- data.frame(var=c("a", "b", "c"), 
    nums=c(1:3))
    plot2 <- ggplot(df, aes(x=var, y=nums)) + 
    geom_bar(stat = "identity")
    print(plot2)
}, interval = 0.01, prof_output = "*_file")

Example taken from http://r-statistics.co/ggplot2-Tutorial-With-R.html

  • Are you tracking things at the same time? It would be helpful if you provided some sort of [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that clearly shows how you are using the two packages and shows a difference in results. – MrFlick Jul 02 '21 at 17:39
  • No, I ran profvis first and then tictoc separately – Heidi Greenark Jul 02 '21 at 17:54
  • Possibly related: https://github.com/rstudio/profvis/issues/72. What OS are you using? – MrFlick Jul 02 '21 at 18:01
  • Thank you, that was helpful and something like I was expecting. I am using Windows. – Heidi Greenark Jul 02 '21 at 18:10

0 Answers0