Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
methods vs functions
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
function
636764.1 Ops/sec
func w/ parm
640595.2 Ops/sec
func w/ return
652979.2 Ops/sec
method
570301.8 Ops/sec
mth w/ parm
610863.9 Ops/sec
mth w/ return
604795.1 Ops/sec
HTML Preparation code:
<div id='test'></div>
Script Preparation code:
window.div = document.getElementById('test'); function add() { console.log(1 + 1) } function add2(parm) { console.log(1 + parm) } function add3(parm) { console.log(1 + parm) return parm; } window.methods = { add() { console.log(1 + 1) }, add2(parm) { console.log(1 + parm) }, add3(parm) { console.log(1 + parm) return parm; }, };
Tests:
function
add();
func w/ parm
add2(1);
func w/ return
add3(1);
method
methods.add();
mth w/ parm
methods.add2(1);
mth w/ return
methods.add3(1);