Test name | Executions per second |
---|---|
class without declared fields | 60087.6 Ops/sec |
class with declared fields | 59892.8 Ops/sec |
// classes declared here can't be accessed in test cases for some reason...
class X {
constructor(foo, bar, baz) {
this.foo = foo;
this.bar = bar;
this.baz = baz;
}
sum() {
return this.foo + this.bar + this.baz;
}
}
let i = 1000;
let y = 0;
while (i--) {
let x = new X(1, 2, 3);
y += x.foo + x.bar + x.baz;
y += x.sum();
}
return y;
class X {
foo;
bar;
baz;
constructor(foo, bar, baz) {
this.foo = foo;
this.bar = bar;
this.baz = baz;
}
sum() {
return this.foo + this.bar + this.baz;
}
}
let i = 1000;
let y = 0;
while (i--) {
let x = new X(1, 2, 3);
y += x.foo + x.bar + x.baz;
y += x.sum();
}
return y;