Package 'shiny.benchmark'

Title: Benchmark the Performance of 'shiny' Applications
Description: Compare performance between different versions of a 'shiny' application based on 'git' references.
Authors: Douglas Azevedo [aut, cre], Appsilon Sp. z o.o. [cph]
Maintainer: Douglas Azevedo <[email protected]>
License: LGPL-3
Version: 0.1.1
Built: 2025-02-12 02:55:46 UTC
Source: https://github.com/appsilon/shiny.benchmark

Help Index


Execute performance tests for a list of commits

Description

Execute performance tests for a list of commits

Usage

benchmark(
  commit_list,
  cypress_dir = NULL,
  shinytest2_dir = NULL,
  tests_pattern = NULL,
  app_dir = getwd(),
  port = 3333,
  use_renv = TRUE,
  renv_prompt = TRUE,
  n_rep = 1,
  debug = FALSE
)

Arguments

commit_list

A list of commit hash codes, branches' names or anything else you can use with git checkout ...

cypress_dir

The directory with tests recorded by Cypress. It can also be a vector of the same size of commit_list

shinytest2_dir

The directory with tests recorded by shinytest2 It can also be a vector of the same size of commit_list

tests_pattern

Cypress/shinytest2 files pattern. E.g. 'performance' It can also be a vector of the same size of commit_list. If it is NULL, all the content in cypress_dir/shinytest2_dir will be used

app_dir

The path to the application root

port

Port to run the app

use_renv

In case it is set as TRUE, package will try to apply renv::restore() in all branches. Otherwise, the current loaded list of packages will be used in all branches.

renv_prompt

Prompt the user before taking any action?

n_rep

Number of replications desired

debug

Logical. TRUE to display all the system messages on runtime

Value

Return a shiny_benchmark object containing the benchmark call, elapsed time and a list with the collected performance times


Run the performance test based on multiple commits using Cypress

Description

Run the performance test based on multiple commits using Cypress

Usage

benchmark_cypress(
  commit_list,
  cypress_dir,
  tests_pattern,
  app_dir,
  port,
  use_renv,
  renv_prompt,
  n_rep,
  debug
)

Arguments

commit_list

A list of commit hash codes, branches' names or anything else you can use with git checkout ...

cypress_dir

The directory with tests recorded by Cypress. It can also be a vector of the same size of commit_list

tests_pattern

Cypress/shinytest2 files pattern. E.g. 'shinytest2' It can also be a vector of the same size of commit_list. If it is NULL, all the content in cypress_dir/shinytest2_dir will be used

app_dir

The path to the application root

port

Port to run the app

use_renv

In case it is set as TRUE, package will try to apply renv::restore() in all branches. Otherwise, the current loaded list of packages will be used in all branches.

renv_prompt

Prompt the user before taking any action?

n_rep

Number of replications desired

debug

Logical. TRUE to display all the system messages on runtime

Value

Return a list with the collected performance times


Run the performance test based on a multiple commits using shinytest2

Description

Run the performance test based on a multiple commits using shinytest2

Usage

benchmark_shinytest2(
  commit_list,
  shinytest2_dir,
  tests_pattern,
  app_dir,
  use_renv,
  renv_prompt,
  n_rep,
  debug
)

Arguments

commit_list

A list of commit hash codes, branches' names or anything else you can use with git checkout ...

shinytest2_dir

The directory with tests recorded by shinytest2 It can also be a vector of the same size of commit_list

tests_pattern

shinytest2 files pattern. E.g. 'performance' It can also be a vector of the same size of commit_list. If it is NULL, all the content in cypress_dir/shinytest2_dir will be used

app_dir

The path to the application root

use_renv

In case it is set as TRUE, package will try to apply renv::restore() in all branches. Otherwise, the current loaded list of packages will be used in all branches.

renv_prompt

Prompt the user before taking any action?

n_rep

Number of replications desired

debug

Logical. TRUE to display all the system messages on runtime

Value

Return a list with the collected performance times


Load an application and instructions to run shiny.benchmark

Description

This function aims to generate a template to be used by shiny.benchmark. It will create the necessary structure on path with some examples of tests using Cypress and shinytest2. Also, a simple application will be added to the folder as well as instructions on how to perform the performance checks. Be aware that a new git repo is need in the selected path.

Usage

load_example(path, force = FALSE)

Arguments

path

A character vector of full path name

force

Create example even if directory does not exist or is not empty

Value

Print on the console instructions to run the example

Examples

load_example(file.path(tempdir(), "example_destination"), force = TRUE)

Plot for shiny_benchmark class

Description

Plot for shiny_benchmark class

Usage

## S3 method for class 'shiny_benchmark'
plot(x, ...)

Arguments

x

shiny_benchmark object

...

Other parameters

Value

Return a ggplot object that compares different git refs


Print for shiny_benchmark class

Description

Print for shiny_benchmark class

Usage

## S3 method for class 'shiny_benchmark'
print(x, ...)

Arguments

x

shiny_benchmark object

...

Other parameters

Value

Print on the console information about the shiny_benchmark object


Run the performance test based on a single commit using Cypress

Description

Run the performance test based on a single commit using Cypress

Usage

run_cypress_ptest(
  commit,
  project_path,
  cypress_dir,
  tests_pattern,
  use_renv,
  renv_prompt,
  n_rep,
  debug
)

Arguments

commit

A commit hash code or a branch's name

project_path

The path to the project with all needed packages installed

cypress_dir

The directory with tests recorded by Cypress

tests_pattern

Cypress files pattern. E.g. 'performance'. If it is NULL, all the content will be used

use_renv

In case it is set as TRUE, package will try to apply renv::restore() in all branches. Otherwise, the current loaded list of packages will be used in all branches.

renv_prompt

Prompt the user before taking any action?

n_rep

Number of replications desired

debug

Logical. TRUE to display all the system messages on runtime

Value

Return a data.frame with the collected performance time


Run the performance test based on a single commit using shinytest2

Description

Run the performance test based on a single commit using shinytest2

Usage

run_shinytest2_ptest(
  commit,
  project_path,
  app_dir,
  shinytest2_dir,
  tests_pattern,
  use_renv,
  renv_prompt,
  n_rep,
  debug
)

Arguments

commit

A commit hash code or a branch's name

project_path

The path to the project

app_dir

The path to the application root

shinytest2_dir

The directory with tests recorded by shinytest2

tests_pattern

shinytest2 files pattern. E.g. 'performance'. If it is NULL, all the content will be used

use_renv

In case it is set as TRUE, package will try to apply renv::restore() in all branches. Otherwise, the current loaded list of packages will be used in all branches.

renv_prompt

Prompt the user before taking any action?

n_rep

Number of replications desired

debug

Logical. TRUE to display all the system messages on runtime

Value

Return a data.frame with the collected performance time


An object of 'shiny_benchmark' class

Description

An object of 'shiny_benchmark' class

Slots

call

Function call

time

Time elapsed

performance

List of measurements (one entry for each commit)


Summary for shiny_benchmark class

Description

Summary for shiny_benchmark class

Usage

## S3 method for class 'shiny_benchmark'
summary(object, ...)

Arguments

object

shiny_benchmark object

...

Other parameters

Value

Return a data.frame with performance tests' summary statistics