Skip to content

Commit

Permalink
Merge pull request #18 from abeimler/develop
Browse files Browse the repository at this point in the history
6.1.0
  • Loading branch information
abeimler authored Feb 22, 2024
2 parents 9ef9c78 + e350da1 commit cbf0a44
Show file tree
Hide file tree
Showing 85 changed files with 2,198 additions and 281 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cpmaddpackage(
GITHUB_REPOSITORY
aminya/project_options
VERSION
0.33.0
0.34.0
# GIT_TAG main
DOWNLOAD_ONLY)
if(project_options_ADDED)
Expand All @@ -34,7 +34,7 @@ run_vcpkg()
# Set the project name and language
project(
ecs-benchmark
VERSION 6.0.0
VERSION 6.1.0
DESCRIPTION "Benchmarks of common ECS (Entity-Component-System)-Frameworks in C++ (or C)"
HOMEPAGE_URL "https://github.com/abeimler/ecs_benchmark"
LANGUAGES CXX C)
Expand Down Expand Up @@ -65,13 +65,14 @@ include(cmake/ProjectOptions.cmake)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(cmake/CPM.cmake)
# PackageProject.cmake will be used to make our target installable
cpmaddpackage("gh:TheLartians/[email protected]")
# PackageProject.cmake will be used to make our target installable https://github.com/TheLartians/PackageProject.cmake
cpmaddpackage("gh:TheLartians/[email protected]")
# https://github.com/TheLartians/Format.cmake
cpmaddpackage(
NAME
Format.cmake
VERSION
1.7.3
1.8.1
GITHUB_REPOSITORY
TheLartians/Format.cmake
OPTIONS
Expand Down
371 changes: 194 additions & 177 deletions README.md

Large diffs are not rendered by default.

49 changes: 30 additions & 19 deletions README.md.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ECS (Entity-Component-System) Frameworks:
* [mustache](https://github.com/kirillochnev/mustache)
* [flecs](https://github.com/SanderMertens/flecs)
* [pico_ecs](https://github.com/empyreanx/pico_headers)
* [gaia-ecs](https://github.com/richardbiely/gaia-ecs)

## TL;DR Results

Expand Down Expand Up @@ -186,7 +187,7 @@ Benchmarks for more common features, such as "Creating entities", "Adding and re
2. `MovementSystem`: Partial-owning group, `registry.group<PositionComponent>(entt::get<const VelocityComponent>)`
3. `MoreComplexSystem`: Full-owning group, `registry.group<PositionComponent, VelocityComponent, DataComponent>()`
* \**** EnTT iterate components via view and uses a [stable component](https://github.com/skypjack/entt/wiki/Crash-Course:-entity-component-system#pointer-stability=) (`StablePositionComponent`)

* \***** gaia-ecs (SoA) iterate via [SoA Layout](https://github.com/richardbiely/gaia-ecs?tab=readme-ov-file#data-layouts) using an `PositionSoA`- and `VelocitySoA`-component



Expand All @@ -210,6 +211,7 @@ Benchmarks for more common features, such as "Creating entities", "Adding and re
2. `MovementSystem`: Partial-owning group, `registry.group<PositionComponent>(entt::get<const VelocityComponent>)`
3. `MoreComplexSystem`: Full-owning group, `registry.group<PositionComponent, VelocityComponent, DataComponent>()`
* \**** EnTT iterate components via view and uses a [stable component](https://github.com/skypjack/entt/wiki/Crash-Course:-entity-component-system#pointer-stability=) (`StablePositionComponent`)
* \***** gaia-ecs (SoA) iterate via [SoA Layout](https://github.com/richardbiely/gaia-ecs?tab=readme-ov-file#data-layouts) using an `PositionSoA`- und `VelocitySoA`-component


## Contributing
Expand All @@ -229,42 +231,51 @@ Read [CONTRIBUTING.md](CONTRIBUTING) for more details.

### Using [Taskfile](https://taskfile.dev/installation/)

1. `git submodule update --init --recursive`
2. Build: `task build`
3. Run (All) Benchmarks: `task benchmark`
4. Plot Graphs: `task plot:all`
0. Install [Taskfile](https://taskfile.dev/installation/)
1. Run Build: `task build`
2. Run (All) Benchmarks: `task benchmark`
3. Plot Graphs: `task plot:all`

Or run `task generate`

You can now find the benchmark-results in [`reports/`](reports/).

_You need python (>=3.9.0) and some [dependencies](scripts/gen-benchmark-report/requirements.txt) to run [gen-benchmark-report](scripts/gen-benchmark-report) (plotting)_
_You need python (>=3.8.0) and some [dependencies](scripts/gen-benchmark-report/requirements.txt) to run [gen-benchmark-report](scripts/gen-benchmark-report) (plotting), install [pipx](https://pipx.pypa.io/stable/installation/) and [poetry](https://python-poetry.org/docs/#installing-with-pipx) `pipx install poetry`._

Then install dependencies for the script:
```bash
pip install -r ./scripts/gen-benchmark-report/requirements.txt
cd ./scripts/gen-benchmark-report && poetry install
```

#### Generate README

```bash
task generate:readme
```


### ~~Step-by-Step~~

1. Configure and build benchmarks, see [Building Details](doc/README_building.md):
1. `git submodule update --init --recursive`
2. `cmake -S . -B ./build`
3. `cmake --build ./build`
1. `cmake -S . -B ./build`
2. `cmake --build ./build`
2. Run benchmark(s), with [`run-benchmarks.sh`](run-benchmarks.sh) or each:
* `./build/benchmark/benchmarks/entt/ecs-benchmark-entt` _(console output)_ _(optional)_
* `./build/benchmark/benchmarks/entt/ecs-benchmark-entt --benchmark_format=json > ./reports/entt.json` _(write json report)_
3. Plot Reports, after generating json reports, see [`plot-results.sh`](plot-results.sh):
1. `python3 ./scripts/gen-benchmark-report -i ./info.json gen-plot ./reports/entityx.json ./reports/entt.json ./reports/ginseng.json ./reports/mustache.json ./reports/openecs.json ./reports/flecs.json` _(generate graphs)_
2. `python3 ./scripts/gen-benchmark-report -i ./info.json gen-results-md ./reports/entityx.json ./reports/entt.json ./reports/ginseng.json ./reports/mustache.json ./reports/openecs.json ./reports/flecs.json` _(generate full report)_
1. `pipx run --spec ./scripts/gen-benchmark-report gen-benchmark-report -i ./info.json gen-plot ./reports/entityx.json ./reports/entt.json ./reports/ginseng.json ./reports/mustache.json ./reports/openecs.json ./reports/flecs.json` _(generate graphs)_
2. `pipx run --spec ./scripts/gen-benchmark-report gen-benchmark-report -i ./info.json gen-results-md ./reports/entityx.json ./reports/entt.json ./reports/ginseng.json ./reports/mustache.json ./reports/openecs.json ./reports/flecs.json` _(generate full report)_


## Links and More

* [Dependency Setup](doc/README_dependencies.md)
* [Building Details](doc/README_building.md)
* Project Template, mix of: [starter_template](https://github.com/cpp-best-practices/gui_starter_template) and [ModernCppStarter](https://github.com/TheLartians/ModernCppStarter)
* [Forked cpp_vcpkg_project](https://github.com/abeimler/cpp_vcpkg_project)
* [Google benchmark](https://github.com/google/benchmark)
* https://github.com/SanderMertens/ecs-faq
* https://github.com/jslee02/awesome-entity-component-system
- [Dependency Setup](doc/README_dependencies.md)
- [Building Details](doc/README_building.md)
- Project Template, mix of: [starter_template](https://github.com/cpp-best-practices/gui_starter_template) and [ModernCppStarter](https://github.com/TheLartians/ModernCppStarter)
- [Forked cpp_vcpkg_project](https://github.com/abeimler/cpp_vcpkg_project)
- [Google benchmark](https://github.com/google/benchmark)
- https://github.com/SanderMertens/ecs-faq
- https://github.com/jslee02/awesome-entity-component-system


### Candidates
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ tasks:

format:
- cmake --build build --target fix-format
- ~/vcpkg/vcpkg format-manifest ./vcpkg.json
#- ~/vcpkg/vcpkg format-manifest ./vcpkg.json

lint:
- cmake --build build --target check-format
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.0
6.1.0
6 changes: 6 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ if(ENABLE_BENCHMARK_PICO_ECS)
add_subdirectory(benchmarks/pico-ecs-extended)
endif()

if(ENABLE_BENCHMARK_GAIA_ECS)
add_subdirectory(benchmarks/gaia-ecs-entities)
add_subdirectory(benchmarks/gaia-ecs)
add_subdirectory(benchmarks/gaia-ecs-extended)
endif()

if(ENABLE_BENCHMARK_OOP)
add_subdirectory(benchmarks/oop)
endif()
5 changes: 3 additions & 2 deletions benchmark/benchmarks/ExtendedECSBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,9 @@ class ExtendedECSBenchmark

public:
template <class Comp, class... Args>
inline static void dummy_each(Comp& comp, Args&&... /*args*/) {
((comp.x = {}));
inline static void dummy_each(Comp& comp, Args&&... args) {
benchmark::DoNotOptimize(comp);
(benchmark::DoNotOptimize(args), ...);
}

template <typename Iterable, typename Func>
Expand Down
15 changes: 15 additions & 0 deletions benchmark/benchmarks/gaia-ecs-entities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(INCLUDE_DIR "include") # must be relative paths
# NOTE: rename project in "ecs-benchmark-myecs"
add_executable(
ecs-benchmark-gaia-ecs-entities
# NOTE: add new benchmarks here
GaiaEcsEntityBenchmarkSuite.cpp GaiaEcsEntityBenchmarkSuite.h)
target_include_directories(
ecs-benchmark-gaia-ecs-entities
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INCLUDE_DIR}>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_DIR}>")
target_link_libraries(ecs-benchmark-gaia-ecs-entities PRIVATE project_warnings project_options)
target_link_libraries(ecs-benchmark-gaia-ecs-entities PRIVATE ecs-benchmark)

# @NOTE: add libs for example here
target_link_libraries(ecs-benchmark-gaia-ecs-entities PRIVATE ecs-benchmark-example-gaia-ecs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "GaiaEcsEntityBenchmarkSuite.h"

static ecs::benchmarks::gaia_ecs::GaiaEcsEntityBenchmarkSuite benchmark_suite;

ECS_ENTITY_BENCHMARKS(benchmark_suite)

/*
static void BM_CreateEntitiesInBulk(benchmark::State& state) {
benchmark_suite.BM_CreateEntitiesInBulk(state);
}
BENCHMARK(BM_CreateEntitiesInBulk)->Apply(ecs::benchmarks::base::BEDefaultArguments);
static void BM_CreateEmptyEntitiesInBulk(benchmark::State& state) {
benchmark_suite.BM_CreateEmptyEntitiesInBulk(state);
}
BENCHMARK(BM_CreateEmptyEntitiesInBulk)->Apply(ecs::benchmarks::base::BEDefaultArguments);
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef ECS_BENCHMARKS_GAIA_ECS_ENTITYBENCHMARK_H_
#define ECS_BENCHMARKS_GAIA_ECS_ENTITYBENCHMARK_H_

#include "EntityBenchmark.h"
#include "gaia-ecs/entities/EntityFactory.h"
#include <utility>


namespace ecs::benchmarks::gaia_ecs {

class GaiaEcsEntityBenchmarkSuite final
: public ecs::benchmarks::base::EntityBenchmark<"gaia-ecs", entities::EntityFactory> {
public:
GaiaEcsEntityBenchmarkSuite() = default;

explicit GaiaEcsEntityBenchmarkSuite(ecs::benchmarks::base::ESCBenchmarkOptions options)
: EntityBenchmark(std::move(options)) {}
};

} // namespace ecs::benchmarks::gaia_ecs

#endif // ECS_BENCHMARKS_GAIA_ECS_ENTITYBENCHMARK_H_
30 changes: 30 additions & 0 deletions benchmark/benchmarks/gaia-ecs-extended/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set(INCLUDE_DIR "include") # must be relative paths

# NOTE: rename project in "ecs-benchmark-myecs"
add_executable(
ecs-benchmark-gaia-ecs-extended
# NOTE: there can only be ONE suite (split into more execs)
GaiaEcsBenchmarkSuite.cpp GaiaEcsBenchmarkSuite.h)
target_include_directories(
ecs-benchmark-gaia-ecs-extended
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INCLUDE_DIR}>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_DIR}>")
target_link_libraries(ecs-benchmark-gaia-ecs-extended PRIVATE project_warnings project_options)
target_link_libraries(ecs-benchmark-gaia-ecs-extended PRIVATE ecs-benchmark)

# @NOTE: add libs for example here
target_link_libraries(ecs-benchmark-gaia-ecs-extended PRIVATE ecs-benchmark-example-gaia-ecs)

add_executable(
ecs-benchmark-gaia-ecs-extended-soa
# NOTE: there can only be ONE suite (split into more execs)
GaiaEcsSoABenchmarkSuite.cpp GaiaEcsSoABenchmarkSuite.h)
target_include_directories(
ecs-benchmark-gaia-ecs-extended-soa
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INCLUDE_DIR}>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_DIR}>")
target_link_libraries(ecs-benchmark-gaia-ecs-extended-soa PRIVATE project_warnings project_options)
target_link_libraries(ecs-benchmark-gaia-ecs-extended-soa PRIVATE ecs-benchmark)

# @NOTE: add libs for example here
target_link_libraries(ecs-benchmark-gaia-ecs-extended-soa PRIVATE ecs-benchmark-example-gaia-ecs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "GaiaEcsBenchmarkSuite.h"

static ecs::benchmarks::gaia_ecs::GaiaEcsBenchmarkSuite benchmark_suite({
.add_more_complex_system = true,
.version = std::nullopt,
});

ECS_COMPLEX_UPDATE_SYSTEMS_BENCHMARKS(benchmark_suite)
ECS_ITERATE_COMPONENTS_BENCHMARKS(benchmark_suite)
69 changes: 69 additions & 0 deletions benchmark/benchmarks/gaia-ecs-extended/GaiaEcsBenchmarkSuite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#ifndef ECS_BENCHMARKS_GAIABENCHMARK_H_
#define ECS_BENCHMARKS_GAIABENCHMARK_H_

#include "ExtendedECSBenchmark.h"
#include "gaia-ecs/GaiaEcsApplication.h"
#include "gaia-ecs/entities/EntityFactory.h"
#include "gaia-ecs/entities/HeroMonsterEntityFactory.h"
#include "gaia-ecs/systems/DataSystem.h"
#include "gaia-ecs/systems/MoreComplexSystem.h"
#include "gaia-ecs/systems/MovementSystem.h"
#include <utility>

namespace ecs::benchmarks::gaia_ecs {

class GaiaEcsBenchmarkSuite final
: public ecs::benchmarks::base::ExtendedECSBenchmark<"gaia-ecs", GaiaEcsApplication, entities::EntityFactory,
entities::HeroMonsterEntityFactory> {
public:
GaiaEcsBenchmarkSuite() = default;

explicit GaiaEcsBenchmarkSuite(ecs::benchmarks::base::ESCBenchmarkOptions options)
: ExtendedECSBenchmark(std::move(options)) {}

void BM_IterateSingleComponent(benchmark::State& state) {
using ComponentOne = ecs::benchmarks::base::components::PositionComponent;

BM_IterateSingleComponentWithPreCreatedView(
state,
[](auto& world) {
return world.query().template all<ComponentOne&>();
},
[&](ComponentOne& comp) {
dummy_each(comp);
});
}

void BM_IterateTwoComponents(benchmark::State& state) {
using ComponentOne = ecs::benchmarks::base::components::PositionComponent;
using ComponentTwo = ecs::benchmarks::base::components::VelocityComponent;

BM_IterateTwoComponentsWithPreCreatedView(
state,
[](auto& world) {
return world.query().template all<ComponentOne&, ComponentTwo&>();
},
[&](ComponentOne& comp, ComponentTwo& comp2) {
dummy_each(comp, comp2);
});
}

void BM_IterateThreeComponentsWithMixedEntities(benchmark::State& state) {
using ComponentOne = ecs::benchmarks::base::components::PositionComponent;
using ComponentTwo = ecs::benchmarks::base::components::VelocityComponent;
using ComponentThree = ecs::benchmarks::base::components::DataComponent;

BM_IterateThreeComponentsWithMixedEntitiesAndPreCreatedView(
state,
[](auto& world) {
return world.query().template all<ComponentOne&, ComponentTwo&, ComponentThree&>();
},
[&](ComponentOne& comp, ComponentTwo& comp2, ComponentThree& comp3) {
dummy_each(comp, comp2, comp3);
});
}
};

} // namespace ecs::benchmarks::gaia_ecs

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "GaiaEcsSoABenchmarkSuite.h"

static ecs::benchmarks::gaia_ecs::GaiaEcsSoABenchmarkSuite soa_benchmark_suite({
.add_more_complex_system = true,
.version = std::nullopt,
});

ECS_COMPLEX_UPDATE_SYSTEMS_BENCHMARKS(soa_benchmark_suite)
// ECS_ITERATE_COMPONENTS_BENCHMARKS(soa_benchmark_suite)
Loading

0 comments on commit cbf0a44

Please sign in to comment.