Init Private vs Public properties revisited 100000 accesses (v19)

Revision 19 of this benchmark created on


Test runner

Ready to run.

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

Revisions

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