benchmarks/commonUtilities.js
function getRandomArray (n) {
  var res = []
    , i, j, temp
    ;

  for (i = 0; i < n; i += 1) { res[i] = i; }

  for (i = n - 1; i >= 1; i -= 1) {
    j = Math.floor((i + 1) * Math.random());
    temp = res[i];
    res[i] = res[j];
    res[j] = temp;
  }

  return res;
}
function getRandomArray (n) {
  var res = []
    , i, j, temp
    ;

  for (i = 0; i < n; i += 1) { res[i] = i; }

  for (i = n - 1; i >= 1; i -= 1) {
    j = Math.floor((i + 1) * Math.random());
    temp = res[i];
    res[i] = res[j];
    res[j] = temp;
  }

  return res;
}
function getRandomArray ( n ) { var res = [ ] , i , j , temp ; for ( i = 0 ; i < n ; i += 1 ) { res [ i ] = i ; } for ( i = n - 1 ; i >= 1 ; i -= 1 ) { j = Math . floor ( ( i + 1 ) * Math . random ( ) ) ; temp = res [ i ] ; res [ i ] = res [ j ] ; res [ j ] = temp ; } return res ; }
Return an array with the numbers from 0 to n-1, in a random order
Uses Fisher Yates algorithm
Useful to get fair tests
Return an array with the numbers from 0 to n - 1 in a random order Uses Fisher Yates algorithm Useful to get fair tests