Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Can JavaScript benefit from the ECS pattern 4
Proper ECS pattern test with only one entity type, three components. Separate loops for ECS.
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/140.0.0.0 Safari/537.36
Browser:
Chrome 140
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
OO-style
507.9 Ops/sec
ECS-style
238.9 Ops/sec
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 maxPoints = 1000000; class PointB { pointObjectsA = new Int32Array( maxPoints ); pointObjectsB = new Int32Array( maxPoints ); pointObjectsC = new Int32Array( maxPoints ); } var test = new PointB( ); for (let i = 0; i < maxPoints; i++) { pointClasses.push(new Point(0, 0)); test.pointObjectsA[ i ] = 0; test.pointObjectsB[ i ] = 0; test.pointObjectsC[ i ] = 100; }
Tests:
OO-style
let i; for ( i = 0; i < maxPoints; i++ ) pointClasses[ i ].tick();
ECS-style
let i; for ( i = 0; i < maxPoints; i++ ) { test.pointObjectsA[ i ] += 2; } for ( i = 0; i < maxPoints; i++ ) { test.pointObjectsB[ i ] += 2; } for ( i = 0; i < maxPoints; i++ ) { test.pointObjectsC[ i ] = 100; }