Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
constructor vs function
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
constructor
75259.1 Ops/sec
function
85236.5 Ops/sec
Script Preparation code:
class Vector { constructor(x, y) { this.x = x this.y = y } } function createVector(x, y) { return { x, y } } window.Vector = Vector window.createVector = createVector
Tests:
constructor
for (let x = 0; x < 100; x++) { for (let y = 0; y < 100; y++) { new Vector(x, y) } }
function
for (let x = 0; x < 100; x++) { for (let y = 0; y < 100; y++) { createVector(x, y) } }