Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Closure v Prototypical Objects 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Instantiation - Closure
45437896.0 Ops/sec
Instantiation - Prototype
81688656.0 Ops/sec
Utilization - Closure
224137568.0 Ops/sec
Utilization - Prototype
239797104.0 Ops/sec
Script Preparation code:
function Foo() { 'use strict'; let self = {}; /**************************************************************************** * Properties ***************************************************************************/ self.foo1 = 15; self.foo2 = 'testing'; self.foo3 = { i: 1, am: 2, a: 3, literal: 4 }; self.foo4 = null; /**************************************************************************** * Methods ***************************************************************************/ self.constructor = function () { self.foo4 = self.foo2 + self.foo1; } self.doFoo1 = function () { return self.foo2; } self.doFoo2 = function () { self.foo1 += 1; return self.foo1; } /**************************************************************************** * Public Exports ***************************************************************************/ self.public = { doFoo1: self.doFoo1, doFoo2: self.doFoo2 } self.constructor(); return self.public; } preFoo = Foo(); function Bar() { this._foo1 = 15; this._foo2 = 'testing'; this._foo3 = { i: 1, am: 2, a: 3, literal: 4 }; this._foo4 = this._foo2 + this._foo1; } Bar.prototype.doFoo1 = function () { return this._foo2; } Bar.prototype.doFoo2 = function () { this._foo1 += 1; return this._foo1; } preBar = new Bar();
Tests:
Instantiation - Closure
let foo = Foo();
Instantiation - Prototype
let bar = new Bar();
Utilization - Closure
let baz = preFoo.doFoo2();
Utilization - Prototype
let baz = preBar.doFoo2();