Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
class with/without declared fields
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:122.0) Gecko/20100101 Firefox/122.0
Browser:
Firefox 122
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
class without declared fields
17663.1 Ops/sec
class with declared fields
5371.9 Ops/sec
Script Preparation code:
// classes declared here can't be accessed in test cases for some reason...
Tests:
class without declared fields
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 with declared fields
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;