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 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Linux
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
class
404436096.0 Ops/sec
object
255610704.0 Ops/sec
function
515567392.0 Ops/sec
extra: for i
473858848.0 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++)