Script Preparation code:
x
 
function getRandomNumberInRange(min = 0, max = 100) {
    return Math.floor(Math.random() * max) + min;
}
function getRandomValueInRange(min = 0, max = 100) {
    const range = max - min + 1;
    const randomBuffer = new Uint32Array(1);
    window.crypto.getRandomValues(randomBuffer);
    const randomNumber = randomBuffer[0];
    const scaledRandomNumber = Math.floor(
        randomNumber / (Math.pow(2, 32) / range)
    );
    return min + scaledRandomNumber;
}
Tests:
  • getRandomNumberInRange

     
    getRandomNumberInRange(0, 5000);
  • getRandomValueInRange

     
    getRandomValueInRange(0, 50000)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    getRandomNumberInRange
    getRandomValueInRange

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Chrome 113 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
getRandomNumberInRange 6575192.0 Ops/sec
getRandomValueInRange 849410.4 Ops/sec