Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Update Typescript Definitions #188

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ea717b
Implement new Component class and ObjectPool
robertlong May 25, 2020
4343c40
Fix tests
robertlong May 25, 2020
713a644
Fix #157 remove entity from _entitiesByNames when removing it
fernandojsg May 28, 2020
c36bd23
Added options to the world. entityPoolSize
fernandojsg May 28, 2020
a8e9f66
Export Entity as _Entity and allow parameter to be set in World const…
fernandojsg May 29, 2020
5dbf6b4
ObjectPool.aquire => acquire
fernandojsg Jun 3, 2020
6760f16
Initial benchmarks
fernandojsg May 29, 2020
38d4ac9
Rebase and adding benchmarks
fernandojsg Jun 5, 2020
1aed01a
bump benchmarker
fernandojsg Jun 5, 2020
18d3d2d
Use Vector3 type in benchmark to match original implementation.
robertlong Jun 5, 2020
b613205
Implement methods on helper components. Pass false for default compon…
robertlong Jun 5, 2020
1396706
Add reset method to component class
robertlong Jun 5, 2020
e2dfd3c
Merge pull request #182 from MozillaReality/feature/component-schema-…
robertlong Jun 5, 2020
b375ade
Merge branch 'dev' into feature/update-typescript-defs
robertlong Jun 7, 2020
eedc15f
Update type definitions
robertlong Jun 7, 2020
b42f4ea
Fix component types
robertlong Jun 7, 2020
2a39caf
Fix prop types definition
robertlong Jun 7, 2020
350a10a
Update builds
robertlong Jun 7, 2020
97700fd
Update SystemStateComponent definitions
robertlong Jun 7, 2020
da2e258
Update docs
robertlong Jun 7, 2020
0a3329c
Add ObjectPool types
robertlong Jun 7, 2020
95153e1
Update entity types
robertlong Jun 7, 2020
c5438a0
Update registerComponent types
robertlong Jun 7, 2020
f6f6716
Update docs
robertlong Jun 7, 2020
7b28a58
Update system type definitions
robertlong Jun 7, 2020
ef13777
Update docs
robertlong Jun 7, 2020
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
255 changes: 255 additions & 0 deletions benchmark_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
{
"groups": [
{
"groupName": "nogroup",
"benchmarks": [
{
"name": "new World({ entityPoolSize: 100k })",
"stats": {
"n": 10,
"min": 22,
"max": 233,
"sum": 1081,
"mean": 108.1,
"variance": 9698.890000000001,
"standard_deviation": 98.48294268552297
}
},
{
"name": "World::createEntity (100k empty, recreating world)",
"stats": {
"n": 10,
"min": 29,
"max": 765,
"sum": 5864,
"mean": 586.4,
"variance": 77451.64000000001,
"standard_deviation": 278.30134746350046
}
},
{
"name": "World::createEntity (100k empty, recreating world (poolSize: 100k))",
"stats": {
"n": 10,
"min": 30,
"max": 724,
"sum": 4664,
"mean": 466.4,
"variance": 41455.64,
"standard_deviation": 203.6065814260433
}
},
{
"name": "World::createEntity (100k empty, recreating world (not measured), entityPoolSize = 100k)",
"stats": {
"n": 10,
"min": 3,
"max": 11,
"sum": 50,
"mean": 5,
"variance": 8.999999999999998,
"standard_deviation": 2.9999999999999996
}
},
{
"name": "World::createEntity(name) (100k empty, recreating world (not measured), entityPoolSize = 100k)",
"stats": {
"n": 10,
"min": 41,
"max": 85,
"sum": 600,
"mean": 60.00000000000001,
"variance": 108.00000000000003,
"standard_deviation": 10.392304845413266
}
},
{
"name": "World::createEntity (100k empty, reuse world, entityPoolSize = 100k * 10)",
"stats": {
"n": 10,
"min": 2,
"max": 10,
"sum": 52,
"mean": 5.200000000000001,
"variance": 6.960000000000001,
"standard_deviation": 2.638181191654584
}
},
{
"name": "Add 1 tagComponent",
"stats": {
"n": 10,
"min": 37,
"max": 66,
"sum": 417,
"mean": 41.7,
"variance": 74.21,
"standard_deviation": 8.614522621712709
}
},
{
"name": "Add 2 tagComponent",
"stats": {
"n": 10,
"min": 82,
"max": 102,
"sum": 909,
"mean": 90.9,
"variance": 38.690000000000055,
"standard_deviation": 6.220128616033599
}
},
{
"name": "Add 3 tagComponent",
"stats": {
"n": 10,
"min": 100,
"max": 122,
"sum": 1065,
"mean": 106.5,
"variance": 38.64999999999998,
"standard_deviation": 6.216912416947819
}
},
{
"name": "Remove 1 tagComponent (100k entities with 1 component)",
"stats": {
"n": 10,
"min": 61,
"max": 81,
"sum": 698,
"mean": 69.80000000000001,
"variance": 38.760000000000055,
"standard_deviation": 6.225752966509357
}
},
{
"name": "Remove 1 tagComponent (100k entities with 3 component)",
"stats": {
"n": 10,
"min": 77,
"max": 83,
"sum": 801,
"mean": 80.10000000000001,
"variance": 3.2900000000000014,
"standard_deviation": 1.813835714721706
}
}
],
"meanAll": 1620.1000000000001,
"sumAll": 16201
},
{
"groupName": "objectpool",
"benchmarks": [
{
"name": "new ObjectPool(TagComponent, 100k)",
"stats": {
"n": 10,
"min": 6,
"max": 107,
"sum": 815,
"mean": 81.5,
"variance": 1398.2500000000002,
"standard_deviation": 37.39318119657647
}
},
{
"name": "new ObjectPool(Component1, 100k)",
"stats": {
"n": 10,
"min": 95,
"max": 101,
"sum": 985,
"mean": 98.5,
"variance": 4.250000000000001,
"standard_deviation": 2.0615528128088303
}
}
],
"meanAll": 180,
"sumAll": 1800
},
{
"groupName": "components",
"benchmarks": [
{
"name": "Entity::addComponent(Component3)",
"stats": {
"n": 10,
"min": 50,
"max": 90,
"sum": 579,
"mean": 57.9,
"variance": 169.89,
"standard_deviation": 13.034185820372517
}
},
{
"name": "Entity::addComponent(Component3)",
"stats": {
"n": 10,
"min": 52,
"max": 72,
"sum": 567,
"mean": 56.7,
"variance": 56.81000000000002,
"standard_deviation": 7.537240874484509
}
},
{
"name": "Entity::removeComponent(Component3)",
"stats": {
"n": 10,
"min": 57,
"max": 74,
"sum": 659,
"mean": 65.89999999999999,
"variance": 32.89,
"standard_deviation": 5.734980383575867
}
},
{
"name": "Entity::removeComponent(Component3)",
"stats": {
"n": 10,
"min": 56,
"max": 68,
"sum": 624,
"mean": 62.400000000000006,
"variance": 14.24,
"standard_deviation": 3.7735924528226414
}
},
{
"name": "Entity::removeComponent(Component3) sync",
"stats": {
"n": 10,
"min": 29,
"max": 56,
"sum": 386,
"mean": 38.6,
"variance": 111.24000000000001,
"standard_deviation": 10.547037498748168
}
},
{
"name": "Entity::removeComponent(Component3) sync",
"stats": {
"n": 10,
"min": 29,
"max": 60,
"sum": 377,
"mean": 37.699999999999996,
"variance": 101.41,
"standard_deviation": 10.070253224224304
}
}
],
"meanAll": 319.2,
"sumAll": 3192
}
],
"meanAll": 2119.3,
"sumAll": 21193
}
124 changes: 124 additions & 0 deletions benchmarks/components.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { World } from "../src";
import { Component3 } from "./helpers/components.js";

export function init(benchmarks) {
benchmarks
.group("components")
.add({
name: "Entity::addComponent(Component3)",
prepare: ctx => {
ctx.world = new World();
ctx.world.registerComponent(Component3);
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity();
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].addComponent(Component3);
}
}
})
.add({
name: "Entity::addComponent(Component3)",
prepare: ctx => {
ctx.world = new World();
ctx.world.registerComponent(Component3);
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity();
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].addComponent(Component3);
}
}
})
.add({
name: "Entity::removeComponent(Component3)",
prepare: ctx => {
ctx.world = new World();
ctx.world.registerComponent(Component3);
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity().addComponent(Component3);
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].removeComponent(
Component3
);
}
}
})
.add({
name: "Entity::removeComponent(Component3)",
prepare: ctx => {
ctx.world = new World();
ctx.world.registerComponent(Component3);
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity().addComponent(Component3);
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].removeComponent(
Component3
);
}
}
})
.add({
name: "Entity::removeComponent(Component3) sync",
prepare: ctx => {
ctx.world = new World();
ctx.world.registerComponent(Component3);
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity().addComponent(Component3);
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].removeComponent(
Component3,
true
);
}
}
})
.add({
name: "Entity::removeComponent(Component3) sync",
prepare: ctx => {
ctx.world = new World();
ctx.world.registerComponent(Component3);
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity().addComponent(Component3);
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].removeComponent(
Component3,
true
);
}
}
});

/*
.add({
name: "Entity::addComponent(Component3) poolsize = entities",
prepare: ctx => {
ctx.world = new World();
for (let i = 0; i < 100000; i++) {
ctx.world.createEntity();
}
},
execute: ctx => {
for (let i = 0; i < 100000; i++) {
ctx.world.entityManager._entities[i].addComponent(Component3);
}
}
});
*/
}
Loading