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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <benchmark/benchmark.h>
#include <game/geoData.h>
namespace {
const GeoData geoDataFixture {GeoData::loadFromAsciiGrid(FIXTURESDIR "height/SD19.asc")};
void
terrainFindPoint(benchmark::State & state)
{
for (auto loop : state) {
benchmark::DoNotOptimize(geoDataFixture.findPoint({315555000, 495556000}));
}
}
void
terrainWalk(benchmark::State & state)
{
const glm::vec2 point {310001000, 490000000};
const GeoData::PointFace start {point, geoDataFixture.findPoint(point)};
for (auto loop : state) {
geoDataFixture.walk(start, {319999000, 500000000}, [](auto step) {
benchmark::DoNotOptimize(step);
});
}
}
void
terrainWalkBoundary(benchmark::State & state)
{
for (auto loop : state) {
geoDataFixture.boundaryWalk([](auto heh) {
benchmark::DoNotOptimize(heh);
});
}
}
void
terrainDeform(benchmark::State & state)
{
std::array<GlobalPosition3D, 3> points {{
{315555000, 495556000, 0},
{315655000, 495556000, 0},
{315655000, 495557000, 0},
}};
for (auto loop : state) {
auto geoData {geoDataFixture};
benchmark::DoNotOptimize(geoData.setHeights(points, GeoData::SetHeightsOpts {.surface = nullptr}));
}
}
}
BENCHMARK(terrainFindPoint);
BENCHMARK(terrainWalk);
BENCHMARK(terrainWalkBoundary);
BENCHMARK(terrainDeform);
BENCHMARK_MAIN();
|