-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
888 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
17 changes: 17 additions & 0 deletions
17
benchmark/benchmarks/gaia-ecs-entities/GaiaEcsEntityBenchmarkSuite.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
*/ |
22 changes: 22 additions & 0 deletions
22
benchmark/benchmarks/gaia-ecs-entities/GaiaEcsEntityBenchmarkSuite.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-extended | ||
# NOTE: add new benchmarks here | ||
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) |
9 changes: 9 additions & 0 deletions
9
benchmark/benchmarks/gaia-ecs-extended/GaiaEcsBenchmarkSuite.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
69
benchmark/benchmarks/gaia-ecs-extended/GaiaEcsBenchmarkSuite.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
# NOTE: add new benchmarks here | ||
GaiaEcsBenchmarkSuite.cpp GaiaEcsBenchmarkSuite.h) | ||
target_include_directories( | ||
ecs-benchmark-gaia-ecs | ||
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 PRIVATE project_warnings project_options) | ||
target_link_libraries(ecs-benchmark-gaia-ecs PRIVATE ecs-benchmark) | ||
|
||
# @NOTE: add libs for example here | ||
target_link_libraries(ecs-benchmark-gaia-ecs PRIVATE ecs-benchmark-example-gaia-ecs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "GaiaEcsBenchmarkSuite.h" | ||
|
||
static ecs::benchmarks::gaia_ecs::GaiaEcsBenchmarkSuite benchmark_suite; | ||
|
||
ECS_UPDATE_SYSTEMS_BENCHMARKS(benchmark_suite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef ECS_BENCHMARKS_GAIA_ECS_BENCHMARK_H_ | ||
#define ECS_BENCHMARKS_GAIA_ECS_BENCHMARK_H_ | ||
|
||
#include "ECSBenchmark.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::ECSBenchmark<"gaia-ecs", GaiaEcsApplication, entities::EntityFactory, | ||
entities::HeroMonsterEntityFactory> { | ||
public: | ||
GaiaEcsBenchmarkSuite() = default; | ||
|
||
explicit GaiaEcsBenchmarkSuite(ecs::benchmarks::base::ESCBenchmarkOptions options) | ||
: ECSBenchmark(std::move(options)) {} | ||
}; | ||
|
||
} // namespace ecs::benchmarks::gaia_ecs | ||
|
||
#endif // ECS_BENCHMARKS_GAIA_ECS_BENCHMARK_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# https://github.com/richardbiely/gaia-ecs | ||
cpmaddpackage( | ||
NAME | ||
gaia | ||
VERSION | ||
0.8.5 | ||
GITHUB_REPOSITORY | ||
richardbiely/gaia-ecs | ||
# TODO: set current version, use main for build fixes | ||
GIT_TAG | ||
main | ||
OPTIONS | ||
"GAIA_BUILD_UNITTEST OFF" | ||
"GAIA_BUILD_BENCHMARK OFF" | ||
"GAIA_BUILD_EXAMPLES OFF" | ||
"GAIA_MAKE_SINGLE_HEADER ON" | ||
DOWNLOAD_ONLY True) | ||
# @FIXME: can not found <gaia.h> header ... use single-header download | ||
if(gaia_ADDED) | ||
add_library(gaia INTERFACE ${gaia_SOURCE_DIR}/include/gaia.h) | ||
add_library(gaia-ecs ALIAS gaia) | ||
target_include_directories(gaia INTERFACE "$<BUILD_INTERFACE:${gaia_SOURCE_DIR}/include>") | ||
target_compile_features(gaia INTERFACE cxx_std_17) | ||
endif() | ||
|
||
set(INCLUDE_DIR "include") # must be relative paths | ||
# NOTE: rename project in "ecs-benchmark-example-myecs" | ||
add_library( | ||
ecs-benchmark-example-gaia-ecs STATIC | ||
# NOTE: add source files here | ||
gaia-ecs/systems/DataSystem.h | ||
gaia-ecs/systems/DataSystem.cpp | ||
gaia-ecs/systems/MoreComplexSystem.h | ||
gaia-ecs/systems/MoreComplexSystem.cpp | ||
gaia-ecs/systems/MovementSystem.h | ||
gaia-ecs/systems/MovementSystem.cpp | ||
gaia-ecs/entities/EntityFactory.h | ||
gaia-ecs/entities/EntityFactory.cpp | ||
gaia-ecs/entities/HeroMonsterEntityFactory.h | ||
gaia-ecs/entities/HeroMonsterEntityFactory.cpp | ||
gaia-ecs/GaiaEcsApplication.h | ||
gaia-ecs/GaiaEcsApplication.cpp | ||
) | ||
add_library(ecs-benchmark::example::gaia-ecs ALIAS ecs-benchmark-example-gaia-ecs) | ||
|
||
target_include_directories( | ||
ecs-benchmark-example-gaia-ecs | ||
PUBLIC "$<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-example-gaia-ecs PRIVATE project_warnings project_options) | ||
target_link_libraries(ecs-benchmark-example-gaia-ecs PUBLIC ecs-benchmark-base) | ||
|
||
# NOTE: add 3rd-party libs here | ||
target_link_system_libraries(ecs-benchmark-example-gaia-ecs PUBLIC gaia) | ||
set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
find_package(Threads REQUIRED) | ||
target_link_libraries(ecs-benchmark-example-gaia-ecs PRIVATE Threads::Threads) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "GaiaEcsApplication.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef ECS_BENCHMARKS_GAIA_ECS_APPLICATION_H_ | ||
#define ECS_BENCHMARKS_GAIA_ECS_APPLICATION_H_ | ||
|
||
#include "base/Application.h" | ||
|
||
#include "systems/DataSystem.h" | ||
#include "systems/MoreComplexSystem.h" | ||
#include "systems/MovementSystem.h" | ||
#include <gaia.h> | ||
|
||
namespace ecs::benchmarks::gaia_ecs { | ||
|
||
class GaiaEcsApplication { | ||
public: | ||
using EntityManager = ::gaia::ecs::World; | ||
using TimeDelta = float; | ||
|
||
GaiaEcsApplication() : m_sm(m_world) {} | ||
|
||
explicit GaiaEcsApplication(bool add_more_complex_system) | ||
: m_add_more_complex_system(add_more_complex_system), m_sm(m_world) {} | ||
|
||
~GaiaEcsApplication() = default; | ||
|
||
GaiaEcsApplication(const GaiaEcsApplication&) = delete; | ||
|
||
GaiaEcsApplication& operator=(const GaiaEcsApplication&) = delete; | ||
|
||
GaiaEcsApplication(GaiaEcsApplication&&) = default; | ||
|
||
GaiaEcsApplication& operator=(GaiaEcsApplication&&) = default; | ||
|
||
[[nodiscard]] inline EntityManager& getEntities() { return m_world; } | ||
|
||
[[nodiscard]] inline const EntityManager& getEntities() const { return m_world; } | ||
|
||
|
||
void init() { | ||
m_sm.add<systems::MovementSystem>(); | ||
m_sm.add<systems::DataSystem>(); | ||
if (m_add_more_complex_system) { | ||
m_sm.add<systems::MoreComplexSystem>(); | ||
m_sm.add<systems::HealthSystem>(); | ||
m_sm.add<systems::DamageSystem>(); | ||
} | ||
} | ||
|
||
void uninit() { | ||
/// @TODO: remove system for better clean up | ||
} | ||
|
||
void update(TimeDelta dt) { m_sm.update(); } | ||
|
||
private: | ||
bool m_add_more_complex_system{false}; | ||
EntityManager m_world; | ||
::gaia::ecs::SystemManager m_sm; | ||
}; | ||
} // namespace ecs::benchmarks::gaia_ecs | ||
|
||
#endif // ECS_BENCHMARKS_GAIA_ECS_APPLICATION_H_ |
Oops, something went wrong.