Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
property accessing
(version: 1)
Comparing performance of:
prototype vs object vs class
Created:
7 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function Egg_Prototype() { this.rotate = 0 } Egg_Prototype.prototype.roll = function() { this.rotate = 180 } function rollEgg() { this.rotate = 180 } function create_egg() { return { rotate: 0, roll: rollEgg } } class Egg { rotate = 0 roll() { this.rotate = 180 } } var output = document.body.appendChild(document.createElement('output'))
Tests:
prototype
var egg = new Egg_Prototype() var r1 = egg.rotate egg.roll() var r2 = egg.rotate output.textContent = r1 + r2
object
var egg = create_egg() var r1 = egg.rotate egg.roll() var r2 = egg.rotate output.textContent = r1 + r2
class
var egg = new Egg() var r1 = egg.rotate egg.roll() var r2 = egg.rotate output.textContent = r1 + r2
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
prototype
object
class
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Browser/OS:
Chrome 140 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
prototype
9569247.0 Ops/sec
object
9658760.0 Ops/sec
class
9791021.0 Ops/sec
Related benchmarks:
Iterate object
Iterate object
Iterate object
Is element in visible dom
Test prototype speed
Test prototype speed
style sheet
createElement vs createDocumentFragment
domrect vs object
Comments
Confirm delete:
Do you really want to delete benchmark?