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_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
class without declared fields
60087.6 Ops/sec
class with declared fields
59892.8 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;