Menu
Open source
randomSeed( int )
Set seed to get a reproducible pseudo-random number using Math.random
.
Parameter | Type | Description |
---|---|---|
int | integer | The seed value. |
Example
Use randomSeed
to get the same random number in all the iterations.
JavaScript
import { randomSeed } from 'k6';
export const options = {
vus: 10,
duration: '5s',
};
export default function () {
randomSeed(123456789);
const rnd = Math.random();
console.log(rnd);
}
Was this page helpful?
Related documentation
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Performance testing and observability in Grafana Cloud
In this webinar, learn how Grafana Cloud k6 offers you the best developer experience for performance testing.
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.