Menu
Scroll for more
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
Open source
randomIntBetween(min, max)
Function returns a random number between the specified range. The returned value is no lower than (and may possibly equal) min, and is no bigger than (and may possibly equal) max.
| Parameter | Type | Description |
|---|---|---|
| min | int | Lower-end bound. Inclusive |
| max | int | Upper-end bound. Inclusive |
Returns
| Type | Description |
|---|---|
| int | Random integer |
Example
JavaScript
JavaScript
import { sleep } from 'k6';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
export default function () {
// code ...
sleep(randomIntBetween(1, 5)); // sleep between 1 and 5 seconds.
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.