summaryrefslogtreecommitdiff
path: root/test/perf-terrain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/perf-terrain.cpp')
-rw-r--r--test/perf-terrain.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/perf-terrain.cpp b/test/perf-terrain.cpp
new file mode 100644
index 0000000..ed6a200
--- /dev/null
+++ b/test/perf-terrain.cpp
@@ -0,0 +1,37 @@
+#include "game/terrain.h"
+#include "gfx/camera.h"
+#include "gfx/gl/sceneShader.h"
+#include "testMainWindow.h"
+#include <benchmark/benchmark.h>
+
+namespace {
+ const TestMainWindowAppBase WINDOW;
+
+ void
+ terrainMeshgen(benchmark::State & state)
+ {
+ Terrain terrain {GeoData::loadFromAsciiGrid(FIXTURESDIR "height/SD19.asc")};
+
+ for (auto loop : state) {
+ terrain.generateMeshes();
+ }
+ }
+
+ void
+ terrainRender(benchmark::State & state)
+ {
+ Terrain terrain {GeoData::loadFromAsciiGrid(FIXTURESDIR "height/SD19.asc")};
+ SceneShader shader;
+ Camera cam {terrain.getExtents().min + GlobalPosition3D {0, 0, 10000}, 45.F, 1.F, 1, 10000};
+ cam.setForward(::north + ::east);
+
+ for (auto loop : state) {
+ terrain.render(shader, cam);
+ }
+ }
+}
+
+BENCHMARK(terrainMeshgen);
+BENCHMARK(terrainRender);
+
+BENCHMARK_MAIN();