Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
class vs object vs function
(version: 1)
Comparing performance of:
class vs object vs function vs extra: for i
Created:
one year ago
by:
Guest
Go to the latest result
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++)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
class
object
function
extra: for i
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0
Browser/OS:
Firefox 149 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
class
801.0M/s
extra: for i
794.1M/s
function
754.3M/s
object
741.4M/s
View exact numbers
Test name
Executions per second
✓
class
800,985,408 Ops/sec
extra: for i
794,089,984 Ops/sec
function
754,322,112 Ops/sec
object
741,438,336 Ops/sec
Related benchmarks
Class vs Function
Property assignment vs Variable assignment
new class vs function returning obj
objct vs function
objct1 vs function1
function vs class with external declarations
Comments
Confirm delete:
Do you really want to delete benchmark?