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
Comparing native, bubble, insertion, selection, merge, natural merge, and quick sort algorithms on a random array.
<script>
/**
* Define "aij" as the global namespace.
*/
var aij = {
/**
* Swap the item in index i with the item in index j.
* @param {Array.<number>} arr The array containing the items.
* @param {number} i The index of the first swapped item.
* @param {number} j The index of the second swapped item.
*/
swap: function(arr, i, j) {
var swapped = arr[i];
arr[i] = arr[j];
arr[j] = swapped;
},
/**
* Verify that an object is an array with more than one element.
* @param {*} obj The object to verify.
* @return {boolean} True if the verified object is an array with at least
* one element.
*/
isSortable: function(obj) {
return obj && toString.call(obj) === '[object Array]' && obj.length > 1;
}
};
</script>
<script src="https://raw.github.com/escherba/algorithms-in-javascript/master/src/bubble-sort.js">
</script>
<script src="https://raw.github.com/escherba/algorithms-in-javascript/master/src/insertion-sort.js">
</script>
<script src="https://raw.github.com/escherba/algorithms-in-javascript/master/src/merge-sort.js">
</script>
<script src="https://raw.github.com/escherba/algorithms-in-javascript/master/src/adaptive-sort.js">
</script>
<script src="https://raw.github.com/escherba/algorithms-in-javascript/master/src/quick-sort.js">
</script>
<script src="https://raw.github.com/escherba/algorithms-in-javascript/master/src/selection-sort.js">
</script>
// Generate array with 10,000 random integers.
var unsortedTestArray = [];
for (var i = 0; i < 10000; i++) {
unsortedTestArray.push(Math.floor(Math.random()*100000));
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Native |
| ready |
BubbleSort |
| ready |
InsertionSort |
| ready |
SelectionSort |
| ready |
MergeSort |
| ready |
AdaptiveSort |
| ready |
QuickSort |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.