Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
function vs class with external declarations
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/18.2 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
function declaration
312081.4 Ops/sec
function expression
312349.5 Ops/sec
class
314659.6 Ops/sec
Script Preparation code:
var arr = 1 var functionExpression = function(item) { arr = item }; function functionDeclaration(item) { arr = item } class Test { constructor() { } addItem(item){ arr = item } } var _test = new Test() function functionClass(item) { _test.addItem(item); }
Tests:
function declaration
arr =2 for (let i = 1; i < 10000; i++) { functionDeclaration(i); }
function expression
arr =1 for (let i = 1; i < 10000; i++) { functionExpression(i); }
class
arr =1 for (let i = 1; i < 10000; i++) { _test.addItem(i); }