diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-04 20:18:16 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-05 01:04:43 +0100 |
commit | bb1a91f129800af25d198df10d033a01b99e0f6a (patch) | |
tree | cf95555512c933d274623e35513b0a59cddddf0a | |
parent | eb47730fa034cd6419ce16de1204f53db725525e (diff) |
bench stuff
-rw-r--r-- | bench/01-dijkstra.cpp | 5 | ||||
-rw-r--r-- | bench/02-loader.cpp | 36 | ||||
-rw-r--r-- | bench/main.cpp | 2 |
3 files changed, 40 insertions, 3 deletions
diff --git a/bench/01-dijkstra.cpp b/bench/01-dijkstra.cpp index aecc885a..66300721 100644 --- a/bench/01-dijkstra.cpp +++ b/bench/01-dijkstra.cpp @@ -10,7 +10,8 @@ namespace floormat { namespace { auto A = astar(); -bool first_run = true; +bool first_run = false; + void Dijkstra(benchmark::State& state) { @@ -65,6 +66,6 @@ void Dijkstra(benchmark::State& state) } // namespace -BENCHMARK(Dijkstra); +BENCHMARK(Dijkstra)->Unit(benchmark::kMillisecond); } // namespace floormat 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 diff --git a/bench/main.cpp b/bench/main.cpp index 80a491ec..7410bf8d 100644 --- a/bench/main.cpp +++ b/bench/main.cpp @@ -29,7 +29,7 @@ int argc_ = 0; // NOLINT bench_app::bench_app(int argc, char** argv) : Application { {argc_, nullptr}, - Configuration{} + Configuration{}.setFlags(Configuration::Flag::QuietLog) }, argc{argc}, argv{argv} { |