jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
stevenbarragan = function(array) {
return array.length == 0 || array.length == 1 ? array : [].concat(
array.shift(),
array.map(function(_,i){return array[i].pop();}),
array.pop().reverse(),
array.map(function(_,i){return array[i].shift();}).reverse(),
stevenbarragan(array)
);
}
haan = function(n) {
var i_snail = function(n, x, y) {
var result = [];
for (var i = x; i <= y; i++) {
result.push(n[x][i]);
}
for (var i = x+1; i <= y; i++) {
result.push(n[i][y]);
}
for (var i = y-1; i >= x; i--) {
result.push(n[y][i]);
}
for (var i = y-1; i >= x+1; i--) {
result.push(n[i][x]);
}
if (x < y) {
return result.concat(i_snail(n, x+1, y-1));
} else {
return result;
}
}
return i_snail(n, 0, n[0].length - 1);
}
snail = function(array) {
var opt = [];
for(var i = 0,l=Math.ceil(array.length/2);i<l;i++){
opt = opt.concat(array.shift());
for(var j = 0;j<array.length-1;j++){
opt.push(array[j].pop());
}
array.length >0?opt = opt.concat(array.pop().reverse()):0;
for(var j = array.length-1;j>=0;j--){
opt.push(array[j].shift());
}
}
return opt;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
stevenbarragan |
| ready |
haan |
| ready |
me |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.