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 generate(num) {
var result = [];
for (var idx = 0; idx < num; ++idx) {
result.push(~~(Math.random() * 100));
}
return result;
}
function radix_sort(arr, idx_begin, idx_end, bit) {
if (!Array.isArray(arr)) return;
idx_begin = (typeof idx_begin === 'undefined') ? 0 : idx_begin;
idx_end = (typeof idx_end === 'undefined') ? arr.length : idx_end;
bit = (typeof bit === 'undefined') ? 31 : bit;
if (idx_begin >= (idx_end - 1) || bit < 0) {
return;
}
var idx = idx_begin;
var idx_ones = idx_end;
mask = 0x1 << bit;
while (idx < idx_ones) {
if (arr[idx] & mask) {
--idx_ones;
var tmp = arr[idx];
arr[idx] = arr[idx_ones];
arr[idx_ones] = tmp;
} else {
++idx;
}
}
radix_sort(arr, idx_begin, idx_ones, bit - 1);
radix_sort(arr, idx_ones, idx_end, bit - 1);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
MSB Radix Sort |
| ready |
Normal Sort |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.