Init
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -100,3 +100,6 @@ Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
# Custom garbage
|
||||
program
|
||||
heaptrack*
|
||||
|
||||
60
test_DKM.cpp
Normal file
60
test_DKM.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <Tourmaline/Containers/DualkeyMap.hpp>
|
||||
#include <Tourmaline/Systems/ECS.hpp>
|
||||
#include <Tourmaline/Systems/Logging.hpp>
|
||||
#include <Tourmaline/Systems/Random.hpp>
|
||||
#include <Tourmaline/Types.hpp>
|
||||
|
||||
#include <any>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <typeindex>
|
||||
|
||||
using namespace Tourmaline::Containers;
|
||||
using namespace Tourmaline::Type;
|
||||
using namespace Tourmaline::Systems;
|
||||
|
||||
struct Transform : public ECS::Component {
|
||||
Transform(int64_t x = 10, int64_t y = 0, int64_t z = -10)
|
||||
: x(x), y(y), z(z) {}
|
||||
int64_t x, y, z;
|
||||
};
|
||||
struct Rotate : public ECS::Component {
|
||||
Rotate(int64_t x = 50, int64_t y = 0, int64_t z = -1) : x(x), y(y), z(z) {}
|
||||
int64_t x, y, z;
|
||||
};
|
||||
struct Scale : public ECS::Component {
|
||||
Scale(int64_t x = 1, int64_t y = 1, int64_t z = 1) : x(x), y(y), z(z) {}
|
||||
int64_t x, y, z;
|
||||
};
|
||||
|
||||
int main() {
|
||||
// Adding random data
|
||||
DualkeyMap<UUID, std::type_index, std::any> DKMtest;
|
||||
for (int x = 0; x < 100000; x++) {
|
||||
UUID currentEntity = Random::GenerateUUID();
|
||||
if (Random::Generate(2) == 0) {
|
||||
DKMtest.Insert(currentEntity, typeid(Transform), Transform());
|
||||
}
|
||||
if (Random::Generate(2) == 0) {
|
||||
DKMtest.Insert(currentEntity, typeid(Rotate), Rotate());
|
||||
}
|
||||
if (Random::Generate(2) == 0) {
|
||||
DKMtest.Insert(currentEntity, typeid(Scale), Scale());
|
||||
}
|
||||
}
|
||||
|
||||
// Actual query
|
||||
auto queryResult = DKMtest.QueryWithAll<std::type_index>(
|
||||
{typeid(Transform), typeid(Rotate), typeid(Scale)});
|
||||
|
||||
std::cout << queryResult.size() << "\n";
|
||||
for (const auto &result : queryResult) {
|
||||
Transform &transform = any_cast<Transform &>(*result.valueQueryResults[0]);
|
||||
Rotate &rotate = any_cast<Rotate &>(*result.valueQueryResults[1]);
|
||||
Scale &scale = any_cast<Scale &>(*result.valueQueryResults[2]);
|
||||
transform.x += Random::Generate(10) - 5;
|
||||
rotate.y -= Random::Generate(10) - 5;
|
||||
scale.z *= Random::Generate(10) - 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
39
test_Hashmap.cpp
Normal file
39
test_Hashmap.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <Tourmaline/Containers/Hashmap.hpp>
|
||||
#include <Tourmaline/Systems/Logging.hpp>
|
||||
#include <string>
|
||||
|
||||
using namespace Tourmaline;
|
||||
int main() {
|
||||
Containers::Hashmap<std::string, std::size_t, 0.75f, 8> count;
|
||||
std::string input = "74 eb ff 5c f0 a9 4f 93 2e e1 1b 47 a4 13 3b 93 ";
|
||||
std::string buffer = "";
|
||||
for (char letter : input) {
|
||||
if (letter == ' ') {
|
||||
if (count.Has(buffer)) {
|
||||
count.Get(buffer)++;
|
||||
} else {
|
||||
count.Insert(buffer, 1);
|
||||
}
|
||||
buffer.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer += letter;
|
||||
}
|
||||
|
||||
for (char letter : input) {
|
||||
if (letter == ' ') {
|
||||
if (count.Has(buffer)) {
|
||||
Systems::Logging::Log(std::format("{} = {}", buffer, count.Get(buffer)),
|
||||
"Test");
|
||||
count.Remove(buffer);
|
||||
}
|
||||
buffer.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer += letter;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
test_allocationsDKM.cpp
Normal file
25
test_allocationsDKM.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <Tourmaline/Containers/DualkeyMap.hpp>
|
||||
#include <Tourmaline/Systems/ECS.hpp>
|
||||
#include <Tourmaline/Systems/Random.hpp>
|
||||
#include <Tourmaline/Types.hpp>
|
||||
#include <any>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace Tourmaline::Containers;
|
||||
using namespace Tourmaline::Type;
|
||||
using namespace Tourmaline::Systems;
|
||||
|
||||
struct Transform : public ECS::Component {
|
||||
Transform(int64_t x = 10, int64_t y = 0, int64_t z = -10)
|
||||
: x(x), y(y), z(z) {}
|
||||
int64_t x, y, z;
|
||||
};
|
||||
|
||||
int main() {
|
||||
DualkeyMap<UUID, std::type_index, std::any> q;
|
||||
for (int x = 0; x < 100000; x++) {
|
||||
q.Insert(Random::GenerateUUID(), typeid(Transform), std::any(Transform()));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
16
test_allocationsECS.cpp
Normal file
16
test_allocationsECS.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <Tourmaline/Containers/DualkeyMap.hpp>
|
||||
#include <Tourmaline/Systems/ECS.hpp>
|
||||
#include <Tourmaline/Systems/Random.hpp>
|
||||
#include <Tourmaline/Types.hpp>
|
||||
|
||||
using namespace Tourmaline::Containers;
|
||||
using namespace Tourmaline::Type;
|
||||
using namespace Tourmaline::Systems;
|
||||
|
||||
int main() {
|
||||
ECS::World gameWorld;
|
||||
for (int x = 0; x < 100000; x++) {
|
||||
gameWorld.CreateEntity();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
33
test_getcomponent.cpp
Normal file
33
test_getcomponent.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <Tourmaline/Containers/DualkeyMap.hpp>
|
||||
#include <Tourmaline/Systems/ECS.hpp>
|
||||
#include <Tourmaline/Systems/ECS/BuiltinComponents.hpp>
|
||||
#include <Tourmaline/Systems/Logging.hpp>
|
||||
#include <Tourmaline/Systems/Random.hpp>
|
||||
#include <Tourmaline/Types.hpp>
|
||||
#include <print>
|
||||
|
||||
using namespace Tourmaline;
|
||||
using namespace Systems;
|
||||
int main() {
|
||||
ECS::World game;
|
||||
auto player = game.CreateEntity();
|
||||
auto &coordinates = game.GetComponent<Components::Position>(player);
|
||||
|
||||
std::print("Entity {}, x = {}, y = {}, z = {}\n", player.asString(),
|
||||
coordinates.x, coordinates.y, coordinates.z);
|
||||
|
||||
/*
|
||||
for (int x = 0; x < 100000; x++) {
|
||||
// Bad idea, for testing we do need to do this
|
||||
game.CreateEntity();
|
||||
}
|
||||
*/
|
||||
|
||||
coordinates.x += 4;
|
||||
coordinates.y -= 2.5;
|
||||
coordinates.z = -10;
|
||||
|
||||
std::print("Entity {}, x = {}, y = {}, z = {}\n", player.asString(),
|
||||
coordinates.x, coordinates.y, coordinates.z);
|
||||
return 0;
|
||||
}
|
||||
72
test_tombstones.cpp
Normal file
72
test_tombstones.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <Tourmaline/Containers/DualkeyMap.hpp>
|
||||
#include <Tourmaline/Systems/ECS.hpp>
|
||||
#include <Tourmaline/Systems/Random.hpp>
|
||||
#include <Tourmaline/Types.hpp>
|
||||
#include <any>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <print>
|
||||
#include <typeindex>
|
||||
|
||||
using namespace Tourmaline::Containers;
|
||||
using namespace Tourmaline::Type;
|
||||
using namespace Tourmaline::Systems;
|
||||
|
||||
struct Transform : public ECS::Component {
|
||||
Transform(int64_t x = 10, int64_t y = 0, int64_t z = -10)
|
||||
: x(x), y(y), z(z) {}
|
||||
int64_t x, y, z;
|
||||
};
|
||||
|
||||
int main() {
|
||||
// [Key1,NULL] = {{Key2, Value},{Key2, Value},{Key2, Value},{Key2, Value}}
|
||||
// [NULL,Key2] = {{Key1, Value},{Key1, Value}}
|
||||
// [Key1,Key2] = Value
|
||||
|
||||
DualkeyMap<UUID, std::type_index, std::any> q;
|
||||
auto p = Random::GenerateUUID();
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(1));
|
||||
q.insert(p, typeid(Transform), Transform(2));
|
||||
q.insert(p, typeid(Transform), Transform(3));
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(4));
|
||||
q.insert(p, typeid(Transform), Transform(5));
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(6));
|
||||
|
||||
for (decltype(q)::QueryResult result :
|
||||
q.query(std::nullopt, typeid(Transform))) {
|
||||
auto &uuid =
|
||||
std::get<std::reference_wrapper<const UUID>>(result.first).get();
|
||||
auto &component = std::any_cast<Transform &>(result.second);
|
||||
|
||||
std::print("{}, {}\n", uuid.asString(), component.x);
|
||||
}
|
||||
|
||||
for (decltype(q)::QueryResult result : q.query(p, std::nullopt)) {
|
||||
auto &component = std::any_cast<Transform &>(result.second);
|
||||
std::print(
|
||||
"{} x = {} y = {} z = {}\n",
|
||||
std::get<std::reference_wrapper<const std::type_index>>(result.first)
|
||||
.get()
|
||||
.name(),
|
||||
component.x, component.y, component.z);
|
||||
}
|
||||
|
||||
std::print("Deleted {} entries as {} as first key\n",
|
||||
q.remove(p, std::nullopt), p.asString());
|
||||
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(-1));
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(-2));
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(-3));
|
||||
q.insert(Random::GenerateUUID(), typeid(Transform), Transform(-4));
|
||||
|
||||
for (decltype(q)::QueryResult result :
|
||||
q.query(std::nullopt, typeid(Transform))) {
|
||||
auto &uuid =
|
||||
std::get<std::reference_wrapper<const UUID>>(result.first).get();
|
||||
auto &component = std::any_cast<Transform &>(result.second);
|
||||
|
||||
std::print("{}, {}\n", uuid.asString(), component.x);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user