Code profiling for Shiny app?

前端 未结 3 1663
谎友^
谎友^ 2020-12-29 05:31

For an R Shiny web app, what are some good ways to run code profiling that show the parts of the Shiny code that are taking the most processing time?

I\'ve got a bi

3条回答
  •  执念已碎
    2020-12-29 06:31

    From my experiences:

    1. Plugin print() in the functions You can find out which function takes most of the time. For example:

    mydebug <- function(msg="[DEBUG]") { DEBUG <- FALSE if (DEBUG) { print(sprintf("%s - %s - %s", msg1, as.character(Sys.time()), as.character(deparse(sys.calls()[[sys.nframe()-1]])))) } } f <- function() { mydebug() ## your original function definitions ..... mydebug() return(...) ## the returned value needs to be after mydebug() }

    1. Use Chrome flame graph to profile

    You can obtain a flame to find out where the time spent (e.g., which JS function? Is it due to layout?).

    For details, refer to: https://developers.google.com/web/tools/chrome-devtools/profile/rendering-tools/analyze-runtime?hl=en

提交回复
热议问题