Getter vs direct access #2

Benchmark created on


Preparation HTML

<script>

const externalService = {
	calculateValue() {
		return Math.random()*Math.random()
	}
}

class Test {
    get value() {
		return externalService.calculateValue()
	}
	getValue() {
		return externalService.calculateValue()
	}
    arrowValue = () => externalService.calculateValue()
}

const test = new Test()
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Getter
const value = test.value
ready
Direct method
const value = test.getValue()
ready
Arrow property
const value = test.arrowValue()
ready

Revisions

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