diff options
Diffstat (limited to 'bench/02-loader.cpp')
-rw-r--r-- | bench/02-loader.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bench/02-loader.cpp b/bench/02-loader.cpp new file mode 100644 index 00000000..6e891ab7 --- /dev/null +++ b/bench/02-loader.cpp @@ -0,0 +1,36 @@ +#include "loader/loader.hpp" +#include "serialize/json-helper.hpp" +#include "serialize/anim.hpp" +#include <Corrade/Containers/ArrayView.h> +#include <Corrade/Containers/StringIterable.h> +#include <Corrade/Utility/Path.h> +#include <benchmark/benchmark.h> + +namespace floormat { + +namespace { + +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<nlohmann::json>>(Path::join(loader.VOBJ_PATH, "vobj.json")); + } + + 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<nlohmann::json>>(Path::join(loader.VOBJ_PATH, "vobj.json")); + } +} + +BENCHMARK(Loader_json)->Unit(benchmark::kMillisecond); + +} // namespace + +} // namespace floormat |