<commit_before># Entity-Component-Systems Benchmark

Simple Benchmark of common Entity-Component-Systems: 
[entityx](https://github.com/alecthomas/entityx) vs. [anax](https://github.com/miguelmartin75/anax) vs. [Artemis-Cpp](https://github.com/vinova/Artemis-Cpp)

## Candidates

### EntityX by @alecthomas

> Entity Component Systems (ECS) are a form of decomposition that completely decouples entity logic and data from the entity "objects" themselves. 
> The Evolve your Hierarchy article provides a solid overview of EC systems and why you should use them.
> 
> EntityX is an EC system that uses C++11 features to provide type-safe component management, event delivery, etc. 
> It was built during the creation of a 2D space shooter.

Version: 1.x and the [`compiler-time`](https://github.com/alecthomas/entityx/tree/experimental/compile_time) Version (2.0 ?)


### anax by @miguelmartin75

> anax is an open source C++ entity system designed to be portable, lightweight and easy to use. 
> It is aimed toward Game Development, however it would be possible to use it for other projects.

Version: 1.x


### Artemis C++ by @vinova

> A C++ port of Artemis Entity System Framework.
> 
> The port was orignially written by <NAME>, in which he used several C++11 features such as deleted function, variadic templates, nullptr, etc… We wanted the framework to be portable, so we removed all C++11 feature usages.

Version: 1.x (2012)





## Benchmark-Framework: [benchpress](https://github.com/blockchaindev/benchpress)

> Why benchpress?
> 
> The modern developer is faced with a rich variety of language alternatives to C++; however, C++ is still the choice of professionals facing demanding performance requirements. Despite this fact, there are few (if any) popular performance benchmarking frameworks.
> 
> Benchpress is inspired by Catch and by Golang's benchmark functionality.

It's simple, light and header-only.

Version: 1.x (2014)






## Compiling

### CMake

I used CMake 3.2 for the build.

 1. change directory to this Folder
 2. `mkdir ./build`
 3. ``cmake -H. -B./build -C./build/CMakeTools/InitializeCache.cmake -DCMAKE_BUILD_TYPE=Release``
 4. `cd ./build`
 5. `make esc_benchmark`


### C++ Compiler

 - modern C++14 Standard (`-std=c++14`)
 - Default CMake Release Flags (`-O3 -DNDEBUG`)
 - some Compiler Warnings (`-Wall -Wextra -Wnon-virtual-dtor -Wcast-align -Woverloaded-virtual -pedantic`)
 - Threading (not used, yet?) (`-pthread`)


I used g++ 6.4.0, clang++ 3.8 should work, too.


#### Linked Libraries

 - entityx (1.x)
 - anax
 - ArtemisCpp

benchpress and entityx (compile-time) are header-only.


#### CMake Configure

| Variable                        | Value   |
|---------------------------------|---------|
| ANAX_32_BIT_ENTITY_IDS          | OFF     |
| ANAX_DEFAULT_ENTITY_POOL_SIZE   | 2097152 |
| ANAX_MAX_AMOUNT_OF_COMPONENTS   | 64      |
| ANAX_USE_VARIADIC_TEMPLATES     | ON      |
| ANAX_VIRTUAL_DTORS_IN_COMPONENT | ON      |
| ENTITYX_DT_TYPE                 | double  |
| ENTITYX_MAX_COMPONENTS          | 64      |

 - Test and Examples are not build
 - Linked Libraries are static builds





## Benchmark

Benchmarks:

 - creating Entities
 - Systems update


### Setup

#### 3 Components
 - PositionComponent
	- `float x,y` 
 - DirectionComponent
	- `float x,y` 
 - ComflabulationComponent
	- `float thingy`
	- `int dingy`
	- `bool mingy`
	- `std::string stringy`

#### 2 Systems
 - MovementSystem
```cpp
		void update(){
			position.x += direction.x * dt;
			position.y += direction.y * dt;
		}
```

 - ComflabSystem
```cpp
		void update(){
			comflab.thingy *= 1.000001f;
			comflab.mingy = !comflab.mingy;
			comflab.dingy++;
		}
```




### benchmark create Entities

Benchmark Code (1 iteration):
```cpp
auto entity = entitymanager.create();

entity.addComponent<PositionComponent>();
entity.addComponent<DirectionComponent>();
entity.addComponent<ComflabulationComponent>();

entity.destroy();
```<commit_msg>update readme #1<commit_after># Entity-Component-Systems Benchmark

Simple Benchmark of common Entity-Component-Systems: 
[entityx](https://github.com/alecthomas/entityx) vs. [anax](https://github.com/miguelmartin75/anax) vs. [Artemis-Cpp](https://github.com/vinova/Artemis-Cpp)

## Candidates

### EntityX by @alecthomas

> Entity Component Systems (ECS) are a form of decomposition that completely decouples entity logic and data from the entity "objects" themselves. 
> The Evolve your Hierarchy article provides a solid overview of EC systems and why you should use them.
> 
> EntityX is an EC system that uses C++11 features to provide type-safe component management, event delivery, etc. 
> It was built during the creation of a 2D space shooter.

Version: 1.x and the [`compiler-time`](https://github.com/alecthomas/entityx/tree/experimental/compile_time) Version (2.0 ?)


### anax by @miguelmartin75

> anax is an open source C++ entity system designed to be portable, lightweight and easy to use. 
> It is aimed toward Game Development, however it would be possible to use it for other projects.

Version: 1.x


### Artemis C++ by @vinova

> A C++ port of Artemis Entity System Framework.
> 
> The port was orignially written by <NAME>, in which he used several C++11 features such as deleted function, variadic templates, nullptr, etc… We wanted the framework to be portable, so we removed all C++11 feature usages.

Version: 1.x (2012)





## Benchmark-Framework: [benchpress](https://github.com/blockchaindev/benchpress)

> Why benchpress?
> 
> The modern developer is faced with a rich variety of language alternatives to C++; however, C++ is still the choice of professionals facing demanding performance requirements. Despite this fact, there are few (if any) popular performance benchmarking frameworks.
> 
> Benchpress is inspired by Catch and by Golang's benchmark functionality.

It's simple, light and header-only.

Version: 1.x (2014)






## Compiling

### CMake

I used CMake 3.2 for the build.

 1. change directory to this Folder
 2. `mkdir ./build`
 3. `cmake -H. -B./build -DCMAKE_BUILD_TYPE=Release -DENTITYX_BUILD_TESTING:BOOL="0" -DENTITYX_BUILD_SHARED:BOOL="0" -DBUILD_TESTING:BOOL="0" -DBUILD_SHARED_LIBS:BOOL="0"`
 4. `cmake --build ./build --target ecs_benchmark`


### C++ Compiler

 - modern C++14 Standard (`-std=c++14`)
 - Default CMake Release Flags (`-O3 -DNDEBUG`)
 - some Compiler Warnings (`-Wall -Wextra -Wnon-virtual-dtor -Wcast-align -Woverloaded-virtual -pedantic`)
 - Threading (not used, yet?) (`-pthread`)


I used g++ 6.4.0, clang++ 3.8 should work, too.


#### Linked Libraries

 - entityx (1.x)
 - anax
 - ArtemisCpp

benchpress and entityx (compile-time) are header-only.


#### CMake Configure

| Variable                        | Value   |
|---------------------------------|---------|
| ANAX_32_BIT_ENTITY_IDS          | OFF     |
| ANAX_DEFAULT_ENTITY_POOL_SIZE   | 2097152 |
| ANAX_MAX_AMOUNT_OF_COMPONENTS   | 64      |
| ANAX_USE_VARIADIC_TEMPLATES     | ON      |
| ANAX_VIRTUAL_DTORS_IN_COMPONENT | ON      |
| ENTITYX_DT_TYPE                 | double  |
| ENTITYX_MAX_COMPONENTS          | 64      |

 - Test and Examples are not build (`-DENTITYX_BUILD_TESTING:BOOL="0" -DBUILD_TESTING:BOOL="0"`)
 - Linked Libraries are static builds (`-DENTITYX_BUILD_SHARED:BOOL="0" -DBUILD_SHARED_LIBS:BOOL="0"`)





## Benchmark

Benchmarks:

 - creating Entities
 - Systems update


### Setup

#### 3 Components
 - PositionComponent
	- `float x,y` 
 - DirectionComponent
	- `float x,y` 
 - ComflabulationComponent
	- `float thingy`
	- `int dingy`
	- `bool mingy`
	- `std::string stringy`

#### 2 Systems
 - MovementSystem
```cpp
		void update() {
			position.x += direction.x * dt;
			position.y += direction.y * dt;
		}
```

 - ComflabSystem
```cpp
		void update() {
			comflab.thingy *= 1.000001f;
			comflab.mingy = !comflab.mingy;
			comflab.dingy++;
		}
```




### benchmark create Entities

Benchmark Code (1 iteration):
```cpp
auto entity = entitymanager.create();

entity.addComponent<PositionComponent>();
entity.addComponent<DirectionComponent>();
entity.addComponent<ComflabulationComponent>();

entity.destroy();
```
{'fraction_non_alphanumeric': 0.12477019242554234, 'fraction_numerical': 0.01715896555950484, 'mean_word_length': 3.5434298440979957, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4242533', 'n_tokens_mistral': 2837, 'n_tokens_neox': 2584, 'n_words': 823}