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 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser:
Firefox 141
Operating system:
Windows
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
OO-style
128.0 Ops/sec
ECS-style
902.2 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; }