random rgb

Benchmark created by beenotung on


Setup

function nextInt(n){
    return Math.floor(Math.random()*n);
  }
  function nextRGB(){
    return [
      nextInt(256),
      nextInt(256),
      nextInt(256),
    ]
  }
  let a = nextInt(256*256)+2;
  let b = nextInt(256*256)+2;
  let x = nextInt(256);
  
  function nextInt2(){
    return x = (a * x + b) % 256;
  }
  function nextRGB2(){
    return [
      nextInt2(),
      nextInt2(),
      nextInt2(),
    ];
  }
  
  let n = 10000;

Test runner

Ready to run.

Testing in
TestOps/sec
using custom random function
nextRGB2();
ready
using built-in native function
nextRGB();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by beenotung on