Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A suite of benchmarks designed to test and compare JavaScript ECS library perfor
| picoes | 6,814 | 4,223 | 12,368 | 2,679 | 4,303 |
| tiny-ecs | 16,391 | 35,488 | 45,760 | 194 | 1,082 |
| uecs | 29,855 | 14,747 | 9,861 | 1,724 | 5,207 |
| elics | 43,719 | 30,758 | 87,590 | 2,761 | 3,694 |

The best result for each benchmark is marked in bold text. Note that run to run variance for these benchmarks is typically 1-4%. Any benchmarks within a few percent of each other should be considered “effectively equal”. The above benchmarks are run on node v17.8.0.

Expand All @@ -44,6 +45,7 @@ The best result for each benchmark is marked in bold text. Note that run to run
- [`tiny-ecs`](https://github.com/bvalosek/tiny-ecs)
- [`uecs`](https://github.com/jprochazk/uecs)
- [`wolf-ecs`](https://github.com/EnderShadow8/wolf-ecs)
- [`elics`](https://github.com/elixr-games/elics)

## Benchmarks

Expand Down
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@lastolivegames/becsy": "0.8.4",
"bitecs": "0.3.34",
"ecsy": "0.4.2",
"elics": "^2.0.4",
"geotic": "4.1.6",
"goodluck": "7.0.0",
"harmony-ecs": "0.0.12",
Expand Down
1 change: 1 addition & 0 deletions src/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const LIBRARIES = [
{ kind: OBJ, name: "picoes" },
{ kind: OBJ, name: "tiny-ecs" },
{ kind: OBJ, name: "uecs" },
{ kind: OBJ, name: "elics" },
];

const BENCHMARKS = {
Expand Down
43 changes: 43 additions & 0 deletions src/cases/elics/add_remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { World, createComponent, createSystem } from "elics";

const A = createComponent({});

const B = createComponent({});

class AddB extends createSystem({
ANotB: { required: [A], excluded: [B] },
}) {
update() {
this.queries.ANotB.entities.forEach((entity) => {
entity.addComponent(B);
});
}
}

class RemoveB extends createSystem({
B: { required: [B] },
}) {
update() {
this.queries.B.entities.forEach((entity) => {
entity.removeComponent(B);
});
}
}

export default (count) => {
let world = new World({ checksOn: false, deferredEntityUpdates: true });

world
.registerComponent(A)
.registerComponent(B)
.registerSystem(AddB)
.registerSystem(RemoveB);

for (let i = 0; i < count; i++) {
world.createEntity().addComponent(A);
}

return () => {
world.update(1, 1);
};
};
43 changes: 43 additions & 0 deletions src/cases/elics/entity_cycle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Types, World, createComponent, createSystem } from "elics";

const A = createComponent({ value: { type: Types.Int16, default: 0 } });

const B = createComponent({ value: { type: Types.Int16, default: 0 } });

class SpawnB extends createSystem({
A: { required: [A] },
}) {
update() {
this.queries.A.entities.forEach((entity) => {
this.world
.createEntity()
.addComponent(B, { value: A.data.value[entity.index] });
});
}
}

class KillB extends createSystem({ B: { required: [B] } }) {
update() {
this.queries.B.entities.forEach((entity) => {
entity.destroy();
});
}
}

export default (count) => {
let world = new World({ checksOn: false });

world
.registerComponent(A)
.registerComponent(B)
.registerSystem(SpawnB)
.registerSystem(KillB);
for (let i = 0; i < count; i++) {
const entity = world.createEntity();
entity.addComponent(A, { value: i });
}

return () => {
world.update(1, 1);
};
};
61 changes: 61 additions & 0 deletions src/cases/elics/frag_iter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Types, World, createComponent, createSystem } from "elics";

const COMPS = Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZ").map((_, _index) =>
createComponent({ value: { type: Types.Int16, default: 0 } })
);

const Z = COMPS[25];

const Data = createComponent({ value: { type: Types.Int16, default: 0 } });

class DataSystem extends createSystem({ data: { required: [Data] } }) {
init() {
this.value = Data.data.value;
}

update() {
this.queries.data.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

class ZSystem extends createSystem({ Z: { required: [Z] } }) {
init() {
this.value = Z.data.value;
}

update() {
this.queries.Z.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

export default (count) => {
let world = new World({ checksOn: false });

COMPS.forEach((Comp) => {
world.registerComponent(Comp);
});

world
.registerComponent(Data)
.registerSystem(DataSystem)
.registerSystem(ZSystem);

for (let i = 0; i < count; i++) {
COMPS.forEach((Comp) => {
world
.createEntity()
.addComponent(Comp, { value: 0 })
.addComponent(Data, { value: 0 });
});
}

return () => {
world.update(1, 1);
};
};
102 changes: 102 additions & 0 deletions src/cases/elics/packed_5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { Types, World, createComponent, createSystem } from "elics";

const A = createComponent({ value: { type: Types.Int16, default: 0 } });
const B = createComponent({ value: { type: Types.Int16, default: 0 } });
const C = createComponent({ value: { type: Types.Int16, default: 0 } });
const D = createComponent({ value: { type: Types.Int16, default: 0 } });
const E = createComponent({ value: { type: Types.Int16, default: 0 } });

class ASystem extends createSystem({ A: { required: [A] } }) {
init() {
this.value = A.data.value;
}

update() {
this.queries.A.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

class BSystem extends createSystem({ B: { required: [B] } }) {
init() {
this.value = B.data.value;
}

update() {
this.queries.B.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

class CSystem extends createSystem({ C: { required: [C] } }) {
init() {
this.value = C.data.value;
}

update() {
this.queries.C.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

class DSystem extends createSystem({ D: { required: [D] } }) {
init() {
this.value = D.data.value;
}

update() {
this.queries.D.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

class ESystem extends createSystem({ E: { required: [E] } }) {
init() {
this.value = E.data.value;
}

update() {
this.queries.E.entities.forEach((entity) => {
const idx = entity.index;
this.value[idx] *= 2;
});
}
}

export default (count) => {
let world = new World({ checksOn: false });

world
.registerComponent(A)
.registerComponent(B)
.registerComponent(C)
.registerComponent(D)
.registerComponent(E)
.registerSystem(ASystem)
.registerSystem(BSystem)
.registerSystem(CSystem)
.registerSystem(DSystem)
.registerSystem(ESystem);

for (let i = 0; i < count; i++) {
world
.createEntity()
.addComponent(A, { value: 0 })
.addComponent(B, { value: 0 })
.addComponent(C, { value: 0 })
.addComponent(D, { value: 0 })
.addComponent(E, { value: 0 });
}

return () => {
world.update(1, 1);
};
};
Loading