Skip to content

Commit

Permalink
23 performance (#108)
Browse files Browse the repository at this point in the history
* defining learning objectives

* ending shinycannon

* ending final presentation

---------

Co-authored-by: Jon Harmon <[email protected]>
  • Loading branch information
AngelFelizR and jonthegeek authored Jul 24, 2024
1 parent 1acc79e commit 990820e
Show file tree
Hide file tree
Showing 217 changed files with 41,012 additions and 77 deletions.
482 changes: 405 additions & 77 deletions 23-performance.Rmd

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions examples/23-performance/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM rocker/tidyverse:4.4.1

RUN apt-get update && apt-get install -y curl

# Download the .deb package
RUN curl -LO https://github.com/rstudio/shinycannon/releases/download/v1.1.3/shinycannon_1.1.3-dd43f6b_amd64.deb

# Install the .deb package
RUN dpkg -i shinycannon_1.1.3-dd43f6b_amd64.deb || apt-get install -y -f

# Clean up
RUN rm shinycannon_1.1.3-dd43f6b_amd64.deb
103 changes: 103 additions & 0 deletions examples/23-performance/Tabsets-App.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
library(shiny)
library(bslib)

# Define UI for random distribution app ----
# Sidebar layout with input and output definitions ----
ui <- page_sidebar(
tags$script(
src = "https://cdn.jsdelivr.net/gh/Appsilon/[email protected]/shiny-tic-toc.min.js"
),

# App title ----
title = "Tabsets",

# Sidebar panel for inputs ----
sidebar = sidebar(

# Input: Select the random distribution type ----
radioButtons(
"dist",
"Distribution type:",
c(
"Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp"
)
),
# br() element to introduce extra vertical spacing ----
br(),
# Input: Slider for the number of observations to generate ----
sliderInput(
"n",
"Number of observations:",
value = 500,
min = 1,
max = 1000
)
),

# Main panel for displaying outputs ----
# Output: A tabset that combines three panels ----
navset_card_underline(
# Panel with plot ----
nav_panel("Plot", plotOutput("plot")),

# Panel with summary ----
nav_panel("Summary", verbatimTextOutput("summary")),

# Panel with table ----
nav_panel("Table", tableOutput("table"))
)
)

# Define server logic for random distribution app ----
server <- function(input, output) {

# Reactive expression to generate the requested distribution ----
# This is called whenever the inputs change. The output functions
# defined below then use the value computed from this expression
d <- reactive({
dist <- switch(
input$dist,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm
)

dist(input$n)
})

# Generate a plot of the data ----
# Also uses the inputs to build the plot label. Note that the
# dependencies on the inputs and the data reactive expression are
# both tracked, and all expressions are called in the sequence
# implied by the dependency graph.
output$plot <- renderPlot({
dist <- input$dist
n <- input$n

hist(
d(),
main = paste("r", dist, "(", n, ")", sep = ""),
col = "#75AADB",
border = "white"
)
})

# Generate a summary of the data ----
output$summary <- renderPrint({
summary(d())
})

# Generate an HTML table view of the data ----
output$table <- renderTable({
d()
})
}

# Create Shiny app ----
shinyApp(ui, server)

70 changes: 70 additions & 0 deletions examples/23-performance/recording.log

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions examples/23-performance/run-rstudio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# run the container with the host cache mounted in the container
docker run -d --rm -ti \
--name Rstudio \
-e DISABLE_AUTH=true \
-p 127.0.0.1:8787:8787 \
-v /home/angelfeliz/Documents/r-projects/r-lib-4.4:/usr/local/lib/R/site-library \
-v /home/angelfeliz/Documents/r-projects:/home/rstudio \
angelfelizr/shinycannon:4.4.1

# We need to wait 1 second
sleep 1

# We need to open the page
chromium http://localhost:8787/

70 changes: 70 additions & 0 deletions examples/23-performance/test_sessions/test1/recording.log

Large diffs are not rendered by default.

203 changes: 203 additions & 0 deletions examples/23-performance/test_sessions/test1/sessions/0_0_0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# http://127.0.0.1:5555 --workers 1 --loaded-duration-minutes 5 --output-dir test_sessions/test1
# {"appUrl":"http://127.0.0.1:5555","debugLog":false,"loadedDurationMinutes":5.0,"logLevel":"WARN","outputDir":"test_sessions/test1","overwriteOutput":false,"recordingPath":"recording.log","workers":1}
session_id,worker_id,iteration,event,timestamp,input_line_number,comment
0,0,0,PLAYER_SESSION_CREATE,1720332631791,0,
0,0,0,REQ_HOME_START,1720332631792,4,
0,0,0,REQ_HOME_END,1720332631893,4,
0,0,0,REQ_GET_START,1720332631894,5,
0,0,0,REQ_GET_END,1720332631899,5,
0,0,0,REQ_GET_START,1720332631899,6,
0,0,0,REQ_GET_END,1720332631928,6,
0,0,0,REQ_GET_START,1720332631928,7,
0,0,0,REQ_GET_END,1720332631940,7,
0,0,0,REQ_GET_START,1720332631940,8,
0,0,0,REQ_GET_END,1720332631947,8,
0,0,0,REQ_GET_START,1720332631947,9,
0,0,0,REQ_GET_END,1720332631958,9,
0,0,0,REQ_GET_START,1720332631958,10,
0,0,0,REQ_GET_END,1720332631983,10,
0,0,0,WS_OPEN_START,1720332631984,11,
0,0,0,WS_OPEN_END,1720332632039,11,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332632039,12,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332632068,12,
0,0,0,REQ_GET_START,1720332632068,12,
0,0,0,REQ_GET_END,1720332632083,12,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332632083,13,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332632101,13,
0,0,0,WS_SEND_START,1720332632102,13,
0,0,0,WS_SEND_END,1720332632103,13,
0,0,0,WS_RECV_INIT_START,1720332632103,14,
0,0,0,WS_RECV_INIT_END,1720332632105,14,
0,0,0,WS_RECV_START,1720332632105,15,
0,0,0,WS_RECV_END,1720332632174,15,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332632174,16,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332633835,16,
0,0,0,WS_SEND_START,1720332633835,16,
0,0,0,WS_SEND_END,1720332633835,16,
0,0,0,WS_RECV_START,1720332633835,17,
0,0,0,WS_RECV_END,1720332633938,17,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332633939,18,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332634690,18,
0,0,0,WS_SEND_START,1720332634690,18,
0,0,0,WS_SEND_END,1720332634690,18,
0,0,0,WS_RECV_START,1720332634691,19,
0,0,0,WS_RECV_END,1720332634745,19,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332634745,20,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332635416,20,
0,0,0,WS_SEND_START,1720332635416,20,
0,0,0,WS_SEND_END,1720332635416,20,
0,0,0,WS_RECV_START,1720332635416,21,
0,0,0,WS_RECV_END,1720332635475,21,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332635475,22,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332636919,22,
0,0,0,WS_SEND_START,1720332636919,22,
0,0,0,WS_SEND_END,1720332636919,22,
0,0,0,WS_RECV_START,1720332636919,23,
0,0,0,WS_RECV_END,1720332636981,23,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332636981,24,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332637364,24,
0,0,0,WS_SEND_START,1720332637364,24,
0,0,0,WS_SEND_END,1720332637364,24,
0,0,0,WS_RECV_START,1720332637364,25,
0,0,0,WS_RECV_END,1720332637422,25,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332637422,26,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332637756,26,
0,0,0,WS_SEND_START,1720332637756,26,
0,0,0,WS_SEND_END,1720332637756,26,
0,0,0,WS_RECV_START,1720332637756,27,
0,0,0,WS_RECV_END,1720332637860,27,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332637860,28,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332638271,28,
0,0,0,WS_SEND_START,1720332638271,28,
0,0,0,WS_SEND_END,1720332638271,28,
0,0,0,WS_RECV_START,1720332638271,29,
0,0,0,WS_RECV_END,1720332638321,29,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332638322,30,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332639042,30,
0,0,0,WS_SEND_START,1720332639042,30,
0,0,0,WS_SEND_END,1720332639042,30,
0,0,0,WS_RECV_START,1720332639042,31,
0,0,0,WS_RECV_END,1720332639145,31,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332639145,32,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332640292,32,
0,0,0,WS_SEND_START,1720332640292,32,
0,0,0,WS_SEND_END,1720332640292,32,
0,0,0,WS_RECV_START,1720332640292,33,
0,0,0,WS_RECV_END,1720332640393,33,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332640394,34,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332641189,34,
0,0,0,WS_SEND_START,1720332641189,34,
0,0,0,WS_SEND_END,1720332641189,34,
0,0,0,WS_RECV_START,1720332641189,35,
0,0,0,WS_RECV_END,1720332641240,35,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332641240,36,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332641838,36,
0,0,0,REQ_GET_START,1720332641838,36,
0,0,0,REQ_GET_END,1720332641851,36,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332641851,37,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332641862,37,
0,0,0,WS_SEND_START,1720332641862,37,
0,0,0,WS_SEND_END,1720332641863,37,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332641863,38,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332641878,38,
0,0,0,WS_SEND_START,1720332641878,38,
0,0,0,WS_SEND_END,1720332641879,38,
0,0,0,WS_RECV_START,1720332641879,39,
0,0,0,WS_RECV_END,1720332641879,39,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332641879,40,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332643426,40,
0,0,0,WS_SEND_START,1720332643426,40,
0,0,0,WS_SEND_END,1720332643426,40,
0,0,0,WS_RECV_START,1720332643426,41,
0,0,0,WS_RECV_END,1720332643472,41,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332643472,42,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332645196,42,
0,0,0,WS_SEND_START,1720332645196,42,
0,0,0,WS_SEND_END,1720332645197,42,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332645197,43,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332645208,43,
0,0,0,WS_SEND_START,1720332645208,43,
0,0,0,WS_SEND_END,1720332645208,43,
0,0,0,WS_RECV_START,1720332645209,44,
0,0,0,WS_RECV_END,1720332645262,44,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332645262,45,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332646038,45,
0,0,0,WS_SEND_START,1720332646038,45,
0,0,0,WS_SEND_END,1720332646039,45,
0,0,0,WS_RECV_START,1720332646039,46,
0,0,0,WS_RECV_END,1720332646071,46,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332646071,47,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332646706,47,
0,0,0,WS_SEND_START,1720332646707,47,
0,0,0,WS_SEND_END,1720332646707,47,
0,0,0,WS_RECV_START,1720332646707,48,
0,0,0,WS_RECV_END,1720332646739,48,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332646739,49,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332648056,49,
0,0,0,WS_SEND_START,1720332648056,49,
0,0,0,WS_SEND_END,1720332648056,49,
0,0,0,WS_RECV_START,1720332648056,50,
0,0,0,WS_RECV_END,1720332648081,50,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332648081,51,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332649119,51,
0,0,0,WS_SEND_START,1720332649119,51,
0,0,0,WS_SEND_END,1720332649120,51,
0,0,0,WS_RECV_START,1720332649120,52,
0,0,0,WS_RECV_END,1720332649142,52,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332649142,53,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332649590,53,
0,0,0,WS_SEND_START,1720332649590,53,
0,0,0,WS_SEND_END,1720332649590,53,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332649590,54,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332649617,54,
0,0,0,WS_SEND_START,1720332649617,54,
0,0,0,WS_SEND_END,1720332649617,54,
0,0,0,WS_RECV_START,1720332649617,55,
0,0,0,WS_RECV_END,1720332649618,55,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332649618,56,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332651458,56,
0,0,0,WS_SEND_START,1720332651458,56,
0,0,0,WS_SEND_END,1720332651458,56,
0,0,0,WS_RECV_START,1720332651458,57,
0,0,0,WS_RECV_END,1720332651504,57,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332651504,58,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332652381,58,
0,0,0,WS_SEND_START,1720332652381,58,
0,0,0,WS_SEND_END,1720332652381,58,
0,0,0,WS_RECV_START,1720332652381,59,
0,0,0,WS_RECV_END,1720332652428,59,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332652428,60,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332653143,60,
0,0,0,WS_SEND_START,1720332653144,60,
0,0,0,WS_SEND_END,1720332653144,60,
0,0,0,WS_RECV_START,1720332653144,61,
0,0,0,WS_RECV_END,1720332653155,61,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332653155,62,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332653692,62,
0,0,0,WS_SEND_START,1720332653692,62,
0,0,0,WS_SEND_END,1720332653693,62,
0,0,0,WS_RECV_START,1720332653693,63,
0,0,0,WS_RECV_END,1720332653706,63,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332653707,64,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332654507,64,
0,0,0,WS_SEND_START,1720332654507,64,
0,0,0,WS_SEND_END,1720332654508,64,
0,0,0,WS_RECV_START,1720332654508,65,
0,0,0,WS_RECV_END,1720332654522,65,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332654522,66,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332654978,66,
0,0,0,WS_SEND_START,1720332654978,66,
0,0,0,WS_SEND_END,1720332654979,66,
0,0,0,WS_RECV_START,1720332654979,67,
0,0,0,WS_RECV_END,1720332654999,67,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332654999,68,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332655604,68,
0,0,0,WS_SEND_START,1720332655605,68,
0,0,0,WS_SEND_END,1720332655605,68,
0,0,0,WS_RECV_START,1720332655605,69,
0,0,0,WS_RECV_END,1720332655625,69,
0,0,0,PLAYBACK_SLEEPBEFORE_START,1720332655625,70,
0,0,0,PLAYBACK_SLEEPBEFORE_END,1720332657778,70,
0,0,0,WS_CLOSE_START,1720332657779,70,
0,0,0,WS_CLOSE_END,1720332657781,70,
0,0,0,PLAYBACK_DONE,1720332657781,0,
Loading

0 comments on commit 990820e

Please sign in to comment.