Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
function
85K/s
constructor
75K/s
View exact numbers
Test name
Executions per second
✓
function
85,237 Ops/sec
constructor
75,259 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) } }