diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-05 14:42:57 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-05 14:46:49 +0100 |
commit | 47124d3af8a80854e9a35d2c4ec4b783dbe501b0 (patch) | |
tree | 57085e5453a43c6a6fcb42e4b184bd810ffc4afc /bench | |
parent | e1e8ab80a5ec95f429e5735f6f678eb0447c0421 (diff) |
bench: now test loader without its cache
Previously it only tested loading the .json files.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/loader.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/bench/loader.cpp b/bench/loader.cpp index ec0eed17..dcd13e4e 100644 --- a/bench/loader.cpp +++ b/bench/loader.cpp @@ -1,4 +1,6 @@ #include "loader/loader.hpp" +#include "loader/ground-info.hpp" +#include "loader/wall-info.hpp" #include "serialize/json-helper.hpp" #include "serialize/anim.hpp" #include <Corrade/Containers/ArrayView.h> @@ -10,25 +12,48 @@ namespace floormat { namespace { +constexpr struct { + const char* name; + Vector2ub size; + pass_mode pass = pass_mode::pass; +} ground_atlases[] = { + { "floor-tiles", {44,4} }, + { "tiles", {8, 5} }, + { "texel", {2, 2}, pass_mode::blocked }, + { "metal1", {2,2} }, +}; + +constexpr const char* wall_atlases[] = { + "concrete1", "empty", "test1", +}; + +constexpr const char* anim_atlases[] = { + "anim/npc-walk", + "anim/test-8x8", + "scenery/door-close", + "scenery/control-panel", + "scenery/table", +}; + using nlohmann::json; +void run() +{ + for (const auto& str : anim_atlases) + (void)loader.get_anim_atlas(str); + for (const auto& x : ground_atlases) + (void)loader.get_ground_atlas(x.name, x.size, x.pass); + for (const auto& name : wall_atlases) + (void)loader.get_wall_atlas(name); +} + void Loader_json(benchmark::State& state) { loader.destroy(); - // warmup - { for (const auto& x : loader.anim_atlas_list()) - json_helper::from_json<anim_def>(Path::join(loader.ANIM_PATH, ""_s.join({x, ".json"}))); - json_helper::from_json<std::vector<json>>(Path::join(loader.VOBJ_PATH, "vobj.json")); - } - + run(); for (auto _ : state) - for (int i = 0; i < 10; i++) - { - for (const auto& x : loader.anim_atlas_list()) - json_helper::from_json<anim_def>(Path::join(loader.ANIM_PATH, ""_s.join({x, ".json"}))); - json_helper::from_json<std::vector<json>>(Path::join(loader.VOBJ_PATH, "vobj.json")); - } + run(); } BENCHMARK(Loader_json)->Unit(benchmark::kMillisecond); |