Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Can JavaScript benefit from the ECS pattern 3
Proper ECS pattern test with only one entity type, three components.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
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:
Chrome Mobile 140
Operating system:
Android
Device Platform:
Mobile
Date tested:
7 months ago
Test name
Executions per second
OO-style
9.0 Ops/sec
ECS-style
10.5 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 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; }