Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
class vs object vs function
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0
Browser:
Opera 124
Operating system:
Windows
Device Platform:
Desktop
Date tested:
8 months ago
object
97.0M/s
class
87.9M/s
extra: for i
83.4M/s
function
78.1M/s
View exact numbers
Test name
Executions per second
✓
object
97,008,744 Ops/sec
class
87,870,208 Ops/sec
extra: for i
83,440,472 Ops/sec
function
78,143,728 Ops/sec
Script Preparation code:
let i = 0; function init() { i++; } const obj = { i: 0, init: function() { this.i++; } }; class sample { constructor() { this.i = 0; this.init(); } init() { this.i++; } } const cls = new sample();
Tests:
class
cls.init();
object
obj.init();
function
init();
extra: for i
for (let i=0; i<1; i++)