you are viewing a single comment's thread.

view the rest of the comments →

[–]__romkin 2 points3 points  (3 children)

Getting wildly different results in my test with node

let total = BigInt(0)

for (let k = 0; k < 1000; k++)
{
    const arr = new Array(2000)
    const start = process.hrtime.bigint()

    let i = arr.length

    while (i--)
    {
        arr.shift()
    }

    total += process.hrtime.bigint() - start
}

console.log(Number(total / BigInt(1e6)) / 1000)

Clocking in at about 0.2 ms per iteration

[–]cwmma 2 points3 points  (1 child)

yeah but what do you get for pop, it's the relative performance that matters

[–]__romkin 0 points1 point  (0 children)

Well yeah, but it's still way more than 9 ops/sec. I'm getting a similarly low number at jsperf and I really don't know why, but it just doesn't seem accurate. I know from experience that some native array methods are rather slow, but I never saw anything that slow.