asdqwdqwd

Benchmark created by blah on


Test runner

Ready to run.

Testing in
TestOps/sec
mucca
function chunk(arr, size) {
    var result = [],
    temp = [];

    for (i=0;i<arr.length;i++){
        temp.push(arr[i]);
        if ((i +1) % size == 0 ){
            result.push(temp);
            temp = [];
        }
    };
    if (temp !== [])
     result.push(temp);
 
  return result;
}
chunk([0, 1, 2, 3, 4, 5], 2);
ready
mann
function chunk(arr, size) {
  var result =[];
  var arrayToPush=[];
  
  var iterations = Math.ceil(arr.length/size);
  var start=0;
  var permanentSize = size;
  for (i=0;i<iterations;i++){
    
    
    arrayToPush = arr.slice(start,size);
    
    result.push(arrayToPush);
    arrayToPush=[];
    start+=permanentSize;
    size+=permanentSize;
  }
  
  
  
  return result;
}
chunk([0, 1, 2, 3, 4, 5], 2);
ready

Revisions

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