ret vs out

Benchmark created on


Setup

function fiboret(a, b) {
  let c = (a + b) % 1000000007
  return [b, c]
}

function fiboout(out) {
  const a = out[0]
  const b = out[1]
  const c = (a + b) % 1000000007
  out[0] = b
  out[1] = c
}

Test runner

Ready to run.

Testing in
TestOps/sec
ret
let a = 0
let b = 1
for (let i = 0; i < 10_000_000; ++i) {
  [a, b] = fiboret(a, b)
}
console.log(b)
ready
out
const buf = [0, 1]
for (let i = 0; i < 10_000_000; ++i) {
  fiboout(buf)
}
console.log(buf[1])
ready

Revisions

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