Skip to contents

Time what a viewer of a QWC2 webmap waits for, from outside the server: the configuration files and viewer bundle, the first complete render of each map theme in headless Chrome (cold and warm), a WMS GetMap at fixed views, and a GetFeatureInfo at a fixed point. Each measurement is repeated n times and reported as a median and 90th percentile, so runs with the same inputs can be compared over time. Budgets for what counts as too slow belong to each deployment, not to rfp.

Usage

rfp_qwc_probe(
  url,
  theme = NULL,
  map_themes = NULL,
  layers = NULL,
  views,
  point = NULL,
  query_layers = NULL,
  gfi_allow_empty = FALSE,
  n = 5,
  size = c(800, 600),
  dpr = 1,
  background = FALSE,
  render = TRUE,
  idle = 1,
  timeout = 120
)

Arguments

url

Character. The webmap's address, e.g. "https://qgis.a11s.one/".

theme

Character. The QWC2 theme id (the t URL parameter). NULL takes themes.json's defaultTheme, or the only theme.

map_themes

Character. Map themes (visibility presets) to render and GetMap. NULL takes every preset the theme carries, or the theme's default layer visibility when it carries none. Ignored when layers is given.

layers

Character. Explicit WMS layer names to measure instead of map themes; reported with target = "layers".

views

Data frame with columns name, x, y (map CRS) and scale, one row per view.

point

Data frame with one row and columns x, y and scale, the GetFeatureInfo location. NULL skips GetFeatureInfo.

query_layers

Character. Layers to query at point; each must be queryable in themes.json.

gfi_allow_empty

Logical. Accept a GetFeatureInfo answer with zero features. Default FALSE, because a query that hits nothing is usually a mistake in point.

n

Integer. Timed repetitions per measurement. Default 5.

size

Integer vector of length 2. Viewport width and height in CSS pixels, also the GetMap size at dpr = 1.

dpr

Numeric. Device pixel ratio for the browser. The GetMap size is size * dpr, and its DPI is 96 at a ratio of 1 and 90 * dpr otherwise, as the viewer sends.

background

Logical. Load the viewer's background layer. Default FALSE (bl=), so a third party's tile server is not in the measure.

render

Logical. Run the headless-browser render rows. Needs the chromote package and Chrome.

idle

Numeric. Seconds with no request open on the map's origin after which a load counts as finished.

timeout

Numeric, at least 1. Seconds before a request or a load is abandoned and reported as an error.

Value

A tibble, one row per measurement (see What is measured).

What is measured

Each row is one measurement, keyed by kind, target, view, scale and cache:

config

index.html, config.json, themes.json and every script index.html loads (the viewer bundle is usually the largest download). A VM-side mapViewerConfig.json is not served, so it cannot be measured from outside.

render

Time from the viewer's document request to the last successful image GetMap on the theme's WMS path, with none still open, read from the browser's own network events. A canceled GetMap does not count. cold is a fresh browser session with its cache cleared; warm is the same navigation again in that session. QWC2 refetches themes.json and every GetMap on a warm load, so warm still waits for the WMS.

render_idle

Time to the end of the last request to the map's own origin, in the same loads. Requests to other hosts, such as a third party's tiles, are excluded.

getmap

The GetMap the viewer would send at that view, sent directly: same layers, order, styles, opacities, size, DPI and format.

getfeatureinfo

A GetFeatureInfo to the theme's featureInfoUrl (what the viewer waits for) at the centre of point.

Columns: median_s, p90_s and ttfb_median_s (time to first byte) in seconds; bytes as wire bytes (what crosses the network) and bytes_decoded beside it; features for GetFeatureInfo; layers (the WMS layers, comma-separated) and request_hash so two runs can be checked for asking the same thing; server_timing (a Server-Timing header, where the server sends one); and times, every repetition. The call's time (UTC), rfp version and arguments are attributes of the result.

Each config, GetMap and GetFeatureInfo target gets one unrecorded warm-up request before its timed repetitions, so a server's first-request cost (QGIS Server loading the project) does not sit in the median. Render repetitions run after the direct requests for the same reason.

The 90th percentile is stats::quantile(type = 7). At small n it is mostly the slowest repetition: at n = 3 it sits 80% of the way from the second to the third value.

Map themes and views

A QWC2 theme (theme, the viewer's t) carries QGIS map themes as visibilityPresets. QWC2 has no URL parameter that selects one, so a render loads the theme with the preset's layers in l=, which reproduces it. A layer draws when its preset key and every ancestor group's key are present.

A view is a centre and a scale. The viewer snaps a scale to the theme's scales without saying so, so a scale that is not one of them is refused.

Every WMS answer is checked rather than trusted: QGIS Server answers a GetMap for an unknown layer with HTTP 200 and an XML ServiceException, and the featureInfoUrl answers an unknown or non-queryable layer with HTTP 200 and an empty response. Both are errors here, as is a render that never finishes by timeout. Each GetMap the browser sends is held to the direct GetMap for the same view (layers and their order, styles, size, DPI, CRS and extent), so the render and getmap rows always time the same map; the size and DPI follow config.json's wmsHidpi and wmsDpi, as the viewer's do.

Requests start from wherever url redirects to, so a viewer and the probe land on the same address. Each render repetition runs in a Chrome process of its own, so a cold load pays connection setup as a first visit does.

Examples

if (FALSE) { # \dontrun{
# Needs a live QWC2 server, and Chrome for the render rows.
res <- rfp_qwc_probe(
  "https://qgis.a11s.one/",
  views = data.frame(name = c("reach", "site"),
                     x = c(970000, 969000), y = c(1050000, 1050500),
                     scale = c(20000, 4000)),
  point = data.frame(x = 974137, y = 1052142, scale = 20000),
  query_layers = "floodplain \u2014 co_ff04",
  n = 3
)
res[, c("kind", "target", "view", "cache", "median_s", "p90_s", "bytes")]
} # }