Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source

randomSeed( int )

Set seed to get a reproducible pseudo-random number using Math.random.

ParameterTypeDescription
intintegerThe 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);
}