shuffle

Benchmark created on


Setup

const array = [...Arrays(1000).keys()];

Test runner

Ready to run.

Testing in
TestOps/sec
shuffle0
  for (let i = array.length - 1; i >= 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
ready
shuffle1
  for (let i = array.length - 1; i >= 1; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
ready

Revisions

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