class variable vs local copy variable

Benchmark created on


Setup

const iterations = 100000
class Test {
	value = 'abc'
	readClassVariable(){
		for(var i=0; i<iterations; i++){
			var x = this.value
		}
	}
	readLocalCopy(){
		var localValue = this.value
		for(var i=0; i<iterations; i++){
			var x = localValue 
		}
	}
}

var instance = new Test()

Test runner

Ready to run.

Testing in
TestOps/sec
readClassVariable
instance.readClassVariable()
ready
readLocalCopy
instance.readLocalCopy()
ready

Revisions

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