blob: ec0eed1722704dda4fb5a98799eedebfc29b1e7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#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 {
using nlohmann::json;
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"));
}
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"));
}
}
BENCHMARK(Loader_json)->Unit(benchmark::kMillisecond);
} // namespace
} // namespace floormat
|