getter vs function get

Benchmark created on


Description

are getters really slower than just calling another function ? getters are so convenient but not if they kill 10x performance

Setup

const O = { a: 1 }
O.getValue = function () { return this.a }
Object.defineProperty( O, `value`, {
    get: O.getValue
} )

Test runner

Ready to run.

Testing in
TestOps/sec
getter
O.value
ready
function get
O.getValue()
ready

Revisions

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