Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
objct vs function
(version: 1)
Comparing performance of:
function vs object
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
pr=function(){ this.a=0; this.add=()=>{ this.a+=1; } } const pro={ a:0, add(){ this.a+=1; } }
Tests:
function
k = new pr(); for (i = 0; i < 1000; i++) { k.add(); }
object
const ob=Object.assign({},pro); for (i = 0; i < 1000; i++) { ob.add(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
function
object
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser/OS:
Firefox 132 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
function
76283.3 Ops/sec
object
333886.2 Ops/sec
Related benchmarks:
Prototype
prototype function
creation
Constructor vs object literal 2
double bang vs typeof check
Class vs Function
Object Assignment vs DefineProperties
Object.create(null) vs {} unknown property
objct1 vs function1
Comments
Confirm delete:
Do you really want to delete benchmark?