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
function qSort(arr, sortFunction) {
if (sortFunction == undefined) {
sortFunction = function(a, b) {
return ((a > b) ? 1 : ((a === b) ? 0 : -1));
};
}
sort(0, arr.length - 1);
function sort(l, r) {
var tmp, s, x,
ltmp = l,
rtmp = r;
s = Math.floor((r + l) / 2);
x = arr[s];
do {
while (sortFunction(arr[l], x) < 0) l++;
while (sortFunction(x, arr[r]) < 0) r--;
if (l <= r) {
if (l < r) {
tmp = arr[l];
arr[l] = arr[r];
arr[r] = tmp;
}
l++;
r--;
}
} while (l <= r)
if (ltmp < r) sort(ltmp, r);
if (l < rtmp) sort(l, rtmp);
}
};
function sortFun(a, b) {
return a - b;
};
function generateArray(length, maxNumber) {
var arr = [];
while (length--) {
arr.push(Math.random() * maxNumber);
}
return arr;
}
function copy(arr) {
var newArr = [];
for (var length = arr.length, i = 0; i < length; ++i) {
newArr[i] = arr[i];
}
return newArr;
}
var bigArray = generateArray(100000, 1000),
arr1 = copy(bigArray),
arr2 = copy(bigArray);
Ready to run.
Test | Ops/sec | |
---|---|---|
Native sort |
| ready |
qSort |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.