I am planning to capture the execution of R code in my shiny application that is deployed on shiny server pro.
library(shiny)
ui <- fluidPage(
### ui code
)
server <- function(input, output, session) {
start_time <- Sys.time()
### server code
end_time <- Sys.time()
speed <- end_time - start_time
if(file.exists("Speed.csv")){
write.table(speed,
file="./Speed.csv",
append = T,
sep=',',
row.names=T,
col.names=F )
} else {
write.csv(speed, "Speed.csv")
}
}
shinyApp(ui, server)
if you see above i have sys.time()
at the first and at the last. THen I am saving/appending to csv file.
I see some big issue here. When the csv is generated here, it shows 0.5 secs. But when I checked manually with stop watch, it is showing me around 18 secs execution time (the time the plots and tables are displayed on screen).
Why is this happening???? There is big difference between 0.5 secs and 18 secs.
One possibility is, 0.5 secs is correct, But the time it is taking to display the plots and tables is taking time.
Can anyone guide me?