Set private vs public properties

Benchmark created on


Setup

class C {
  #pri;
  _pro;
  pub;
  set pri(val) {
    this.#pri = val;
  }
  set pro(val) {
    this._pro = val;
  }
  setPri(val) {
    this.#pri = val;
  }
  setPro(val) {
    this._pro = val;
  }
}
const c = new C;

Test runner

Ready to run.

Testing in
TestOps/sec
public property
c.pub = 1;
ready
"protected" setter
c.pro = 1;
ready
private setter
c.pri = 1;
ready
setPro
c.setPro(1);
ready
setPri
c.setPri(1);
ready

Revisions

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