Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
objct vs function vs class
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser:
Firefox 132
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
object with extern method
141K/s
class
133K/s
object
129K/s
function
38K/s
View exact numbers
Test name
Executions per second
✓
object with extern method
140,920 Ops/sec
class
133,418 Ops/sec
object
129,385 Ops/sec
function
38,338 Ops/sec
Script Preparation code:
pr=function(){ let a=0; this.add=()=>{ a+=1; } }; const pro={ a:0, add(){ const $=this; $.a+=1; } }; const pro2=Object.assign({},pro); pro2.add2=function(){ const $=this; $.a+=1; }; class Pr { constructor() { this.a = 0; } add() { this.a += 1; } } let c=0;
Tests:
function
k = new pr(); for(c=0;c<1000;c++){ k.add(); }
object
const ob=Object.assign({},pro); for(c=0;c<1000;c++){ ob.add(); }
object with extern method
const ob2=Object.assign({},pro2); for(c=0;c<1000;c++){ ob2.add2(); }
class
j=new Pr(); for(c=0;c<1000;c++){ j.add(); }