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
<script>
var myList = [1, 3, 6, 10, 14, 15, 18, 20, 25, 33, 36, 40, 43, 44, 48, 50];
function binary_search_iterative3(arr, ele) {
var beginning = 0,
end = arr.length,
target,
item;
while (true) {
target = ((beginning + end) >> 1);
item = arr[target];
if ((target === end || target === beginning) && item !== ele) {
return -1;
}
if (item > ele) {
end = target;
} else if (item < ele) {
beginning = target;
} else {
return target;
}
}
}
function binary_search_iterative2(arr, ele) {
var beginning = 0, end = arr.length,
target;
while (true) {
target = ((beginning + end) >> 1);
if ((target === end || target === beginning) && arr[target] !== ele) {
return -1;
}
if (arr[target] > ele) {
end = target;
} else if (arr[target] < ele) {
beginning = target;
} else {
return target;
}
}
}
function binary_search_iterative(arr, ele) {
var beginning = 0, end = arr.length,
target;
while (true) {
target = Math.floor((beginning + end) / 2);
if ((target === end || target === beginning) && arr[target] !== ele) {
return -1;
}
if (arr[target] > ele) {
end = target;
} else if (arr[target] < ele) {
beginning = target;
} else {
return target;
}
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
new |
| ready |
new.old |
| ready |
original |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.