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 getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function binarySearch(arr, target) {
let low = 0;
let high = arr.length - 1;
while (low <= high) {
const mid = Math.floor((low + high) / 2);
if (arr[mid] === target) {
return mid;
} else if (arr[mid] < target) {
low = mid + 1;
} else {
high = mid - 1;
}
}
return -1; // Target not found
}
const MAX = 10_000_000;
const array = new Array(MAX).keys().toArray();
const x = getRandomInt(0, MAX);
const y = getRandomInt(0, MAX);
const int = getRandomInt(Math.min(x, y), Math.max(x, y))
Ready to run.
Test | Ops/sec | |
---|---|---|
linear search |
| ready |
for loop |
| ready |
binary search |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.