Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Can JavaScript benefit from the ECS pattern 3
(version: 1)
Proper ECS pattern test with only one entity type, three components.
Comparing performance of:
OO-style vs ECS-style
Created:
8 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
class Point { constructor(x, y) { this.x = x; this.y = y; this.health = 100; } tick() { this.x += 2; this.y += 2; this.health -= 1; } } var pointClasses = []; var pointObjectsA = new Int32Array( 1000000 ); var pointObjectsB = new Int32Array( 1000000 ); var pointObjectsC = new Int32Array( 1000000 ); for (let i = 0; i < 1000000; i++) { pointClasses.push(new Point(0, 0)); pointObjectsA[ i ] = 0; pointObjectsB[ i ] = 0; pointObjectsC[ i ] = 100; }
Tests:
OO-style
let i; for ( i = 0; i < 1000000; i++ ) pointClasses[ i ].tick();
ECS-style
let i; for ( i = 0; i < 1000000; i++ ) { pointObjectsA[ i ] += 2; pointObjectsB[ i ] += 2; pointObjectsC[ i ] = 100; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
OO-style
ECS-style
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36
Browser/OS:
Chrome Mobile 140 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
OO-style
8.8 Ops/sec
ECS-style
10.3 Ops/sec
Related benchmarks:
complex values for reduce 1
FP vs OOP vs fake OOP 3
literals vs classes
ES6 Class vs Prototype vs Object Literal 4
Long and dynamic Inheritance => Prototype vs Object Literal - v1
Long and dynamic Inheritance => Prototype vs Object Literal - v2
ES6 Class vs Object Literal 100k runs
Hidden class test
ES6 Class vs Prototype vs Object Literal v3
Comments
Confirm delete:
Do you really want to delete benchmark?