Init Private vs Public properties revisited (v17)

Revision 17 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
private field
class C { #pri; get p(){return this.#pri;} }
const c = new C();
for(let i = 0; i < 100; ++i){
	let b = c.p;
}
ready
public field
class C { pub; get p(){return this.pub;} }
const c = new C();
for(let i = 0; i < 100; ++i){
	let b = c.p;
}
ready
pub in constructor
class C { 
  constructor() { this.pub = 42; }
  get p(){return this.pub;}
}
const c = new C();
for(let i = 0; i < 100; ++i){
	let b = c.p;
}
ready
#pri in constructor
class C {
  #pri;
  constructor() { this.#pri = 42; }
  get p(){return this.#pri;}
}
const c = new C();
for(let i = 0; i < 100; ++i){
	let b = c.p;
}
ready

Revisions

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