getters setters performance (v6)

Revision 6 of this benchmark created on


Setup

class Foo {
	_a = 0
	
	set 0(val) {
		this._a = val
	}
	
	get 0() {
		return this._a
	}
}

class Bar {
  constructor() {
    this[0] = 1
  }
}

const plainArray = [0];

const foo = new Foo()
const bar = new Bar()

Test runner

Ready to run.

Testing in
TestOps/sec
Class getters
foo[0]
ready
Class setters
foo[0] += 1
ready
Plain Array get
plainArray[0]
ready
Plain Array set
plainArray[0] += 1
ready
Bar get 0
bar[0]
ready
Bar set 0
bar[0] += 1
ready

Revisions

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