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
class ListNode {
value = undefined;
prev = null;
next = null;
constructor(value) {
this.value = value;
}
}
class Queue {
#cursor = null;
#tail = null;
push(value) {
const node = new ListNode(value);
if (this.#tail) {
this.#tail.next = node;
this.#tail = this.#tail.next;
return;
}
if (!this.#cursor) {
this.#cursor = node;
this.#tail = node;
return;
}
}
shift() {
if (!this.#cursor) {
return null;
}
const { value } = this.#cursor;
this.#cursor = this.#cursor.next;
return value;
}
}
const queue1 = new Queue();
const queue2 = [];
for (var i = 0;i<1000000;i++) {
queue1.push(i);
queue2.push(i);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Linked List Queue.shift() |
| ready |
Array.shift() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.