PerfPlugin: Performance Tools Plugin

Description Super classes Methods

Description

Provide a set of utilities to profile handling. You can profile or benchmark specific routes, specific handlers within routes, or load test the whole application itself.

Super classes

webtools::Configurable -> webtools::Plugin -> webtools::DispatchPlugin -> PerfPlugin

Methods

Public methods

Inherited methods

Method new()

Create a new PerfPlugin

Usage
PerfPlugin$new()

Method profile()

Profile a request passed through the handler stacks, pass route name in order to profile just a specific route.

Usage
PerfPlugin$profile(
  path = "/",
  url = NULL,
  router = NULL,
  message = NULL,
  binary = FALSE,
  method = "get",
  base_path = "",
  content = "",
  headers = list(),
  trust = TRUE,
  attach = c("request", "message", "header"),
  interval = 0.005,
  close = TRUE,
  ...
)
Arguments
path

(str) path to be hit by the request

url

(str) URL of the request

router

(str) route name

message

(str) message glue string

binary

(flg) is the message a binary message?

method

(str) HTTP method

base_path

(str) root; stripped out of the path when handling requests

content

(str) content of the request

headers

(lst) list of request headers of the test request

trust

(flg) indicates whether request should be trusted

attach

(str) whether to use the request, message, or header stack

interval

(num) loop interval for profiling

close

(flg) if this is not a route, then close the connection?

...

(arg) additional arguments to fiery::fake_request()


Method benchmark()

Measure the times needed to run through handler stack, pass route name in order to benchmark a specific route

Usage
PerfPlugin$benchmark(
  path = "/",
  url = NULL,
  router = NULL,
  message = NULL,
  binary = FALSE,
  method = "get",
  base_path = "",
  content = "",
  headers = list(),
  trust = TRUE,
  attach = c("request", "message", "header"),
  times = 100L,
  close = TRUE,
  ...
)
Arguments
path

(str) path to be hit by the request

url

(str) URL of the request

router

(str) route name

message

(str) message glue string

binary

(flg) is the message a binary message?

method

(str) HTTP method

base_path

(str) root; stripped out of the path when handling requests

content

(str) content of the request

headers

(lst) list of request headers of the test request

trust

(flg) indicates whether request should be trusted

attach

(str) whether to use the request, message, or header stack

times

(int) number of times to run the expression

close

(flg) if this is not a route, then close the connection?

...

(arg) additional arguments to fiery::fake_request()


Method load_test()

Run a load test on the application; this works by spinning up the application on the main thread and running an RStudio job to do the load test.

Usage
PerfPlugin$load_test(
  path = "/",
  method = "GET",
  threads = future::availableCores() * 2L,
  loops = 64L,
  headers = NULL,
  body = NULL,
  encode = c("raw", "json"),
  ramp = 0L,
  delay = 0L,
  wait = 0L
)
Arguments
path

(str) path to be hit by the request

method

(str) HTTP method

threads

(int) number of threads being run

loops

(int) number of times each thread will run a hit

headers

(lst) list of headers to send with the request

body

(lst) list to send as body of request

encode

(str) either "json" or "raw"

ramp

(str) number of seconds before all threads are firing

delay

(str) delay for each request from the load tester

wait

(int) seconds to wait before starting load test


Method clone()

The objects of this class are cloneable with this method.

Usage
PerfPlugin$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


tjpalanca/webtools documentation built on Dec. 23, 2021, 11 a.m.