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
function createListForValues(values) {
const len = values.length;
let previous = {
value: values[0],
previous: undefined,
next: undefined
};
const list = {
head: previous,
tail: undefined,
size: len
};
for (let i = 1; i < len; ++i) {
previous = previous.next = {
value: values[i],
previous: previous,
next: undefined
};
}
list.tail = previous;
return list;
}
function sumList(list) {
let node = list.head;
let sum = 0;
while (node) {
sum += node.value;
node = node.next;
}
return sum;
}
function sumListSized(list) {
const len = list.size;
let node = list.head;
let sum = 0;
for (let i = 0; i < len; ++i) {
sum += node.value;
node = node.next;
}
return sum;
}
function sumArray(array) {
const len = array.length;
let sum = 0;
for (let i = 0; i < len; ++i)
sum += array[i];
return sum;
}
const N = 1000;
const array = Array(N);
for (let i = 0; i < N; ++i) {
array[i] = ~~(Math.random() * 100);
}
const list = createListForValues(array);
Ready to run.
Test | Ops/sec | |
---|---|---|
Array |
| ready |
Linked list unsized |
| ready |
Linked list sized |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.