R code
R runs through WebR, R compiled to WebAssembly. It is the language to use when the check you care about is statistical rather than structural: response-time distribution, error rate, rolling averages.
The API
Section titled “The API”| Symbol | Role |
|---|---|
input | The value received on the input port |
vars | The run variables |
cat(...), print(...) | Write to the execution log |
| The last expression | Its value leaves on the result port |
Scalars are unwrapped; a named list comes back out as a JSON object.
Example
Section titled “Example”temps <- unlist(input$temps_ms)
moyenne <- mean(temps)p95 <- quantile(temps, 0.95)
cat(sprintf("moyenne %.1f ms, p95 %.1f ms\n", moyenne, p95))
list(moyenne = moyenne, p95 = unname(p95), n = length(temps))Wire the output onto an lt Assert to
fail the run if the p95 exceeds your budget.
External packages
Section titled “External packages”The packages field accepts CRAN packages, served from WebR’s WebAssembly
repository.
Things worth knowing
Section titled “Things worth knowing”The R engine is a shared singleton, whose runs are queued. A long R script
therefore delays the others in the same run — keep them short, or raise the
timeout accordingly.