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>
function getRandom() {
return Math.floor(Math.random() * 10000);
}
var findLocationLogarithmic = function(n, arr) {
var left = 0;
var right = arr.length - 1;
while (left <= right){
var mid = Math.floor((left + right) / 2);
if (arr[mid] == n)
return mid;
else if (arr[mid] < n)
left = mid + 1;
else
right = mid - 1;
}
return arr.length;
}
var findLocationLinear = function(n, arr) {
var i, len = arr.length;
for (i = 0; i < len; i++) {
if (arr[i] >= n) return i;
}
return len;
}
</script>
var largeArray = [];
for (var n = 0; n < 10000; n++) {
largeArray.push(n);
}
delete largeArray;
Ready to run.
Test | Ops/sec | |
---|---|---|
push() and sort() |
| ready |
splice() with logarithmic search |
| ready |
splice() with linear search |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.