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 src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
Array.prototype.binarySearchFast = function(search) {
var size = this.length,
high = size -1,
low = 0;
while (high > low) {
if (this[low] === search) return low;
else if (this[high] === search) return high;
target = (((search - this[low]) / (this[high] - this[low])) * (high - low)) >>> 0;
if (this[target] === search) return target;
else if (search > this[target]) low = target + 1, high--;
else high = target - 1, low++;
}
return -1;
};
Array.prototype.binarySearch = function(find) {
var low = 0, high = this.length - 1,
i, comparison;
while (low <= high) {
i = Math.floor((low + high) / 2);
if (this[i] < find) { low = i + 1; continue; };
if (this[i] > find) { high = i - 1; continue; };
return i;
}
return null;
};
for (var i = 0, arr = [], find = 0; i < 100000; i += 100) {
arr.push(i + Math.round(Math.random() * 100));
}
var find = arr[Math.round(arr.length * Math.random())];
Ready to run.
Test | Ops/sec | |
---|---|---|
binarySearchFast |
| ready |
binarySearchSlow |
| ready |
indexOf |
| ready |
jQuery |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.