X

Benchmark created on


Setup

let x = { next: undefined };
for (let i = 0; i < 100; i++) {
    x = { next: x };
}
let x2 = { next: undefined };
let x2holder = [x2];
for (let i = 0; i < 100; i++) {
    const x2Item = { next: new WeakRef(x2) };
    x2holder.push(x2Item);
    x2 = x2Item;
}

Test runner

Ready to run.

Testing in
TestOps/sec
ref
    let y = x;
    for (let i = 0; i < 100; i++) {
        y = y.next;
    }
ready
weak
    let y = x2;
    for (let i = 0; i < 100; i++) {
        y = y.next.deref();
    }
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.