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
Minimalistic implementation of a linked list, used to compare the performance of population and iteration a linked list implementation and a standard Array.
<script>
function MakeNode(newNode) {
newNode._previous = undefined;
newNode._next = undefined;
return newNode;
};
function LinkedList() {
this.first = undefined;
this.last = undefined;
};
LinkedList.prototype.add = function(node) {
if (this.first) //If it's not empty
{
this.last._next = node;
node._previous = this.last;
this.last = node;
}
else { //If it's the first one
this.first = this.last = node;
}
}
function populateArray(amount) {
ar = [];
for (var i = 0; i < amount; i++) {
ar.push({x:Math.random()});
}
return ar;
}
function populateLinkedList(amount) {
ll = new LinkedList();
for (var i = 0; i < amount; i++) {
ll.add(MakeNode({x:Math.random()}));
}
return ll;
}
function doSomething(value) {
return value + "string concatination";
}
function iterateArray(array) {
for (var i = 0, l = array.length; i < l; ++i) {
doSomething(array[i]);
}
}
function iterateLinkedList(list) {
for (var node = list.first; node; node = node._next) {
doSomething(node);
}
}
array25 = populateArray(25);
array100 = populateArray(100);
ll25 = populateLinkedList(25);
ll100 = populateLinkedList(100);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
array insertion x 100K |
| ready |
linked list insertion x 100K |
| ready |
array insertion x 100 |
| ready |
linked list insertion x 100 |
| ready |
iterate array 25 |
| ready |
iterate linked list 25 |
| ready |
iterate array 100 |
| ready |
iterate linked list 100 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.