23.3 Profiling

Where is the app slow / memory-hungry?

23.3.1 Tools

  • profvis

The call stack and the “Flame graph”

library(profvis)

f <- function() {
    pause(0.2)
  g()
    h()
    10
}
g <- function() {
    pause(0.1)
  h()
}
h <- function() {
    pause(0.3)
}

profvis::profvis(f())

Similar for {shiny}, but need explicit call to start the app (and close it with [Ctrl-C])

ui <- fluidPage(
    actionButton("x", "Push me"),
      textOutput("y")
    )
server <- function(input, output, session) {
    output$y <- eventReactive(input$x, f())
}

app <- shinyApp(ui, server)
profvis::profvis(
  shiny::runApp(
    app()
  )
)

Note that data downloads may not be tracked.