summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-05 03:31:44 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-05 03:31:44 +0000
commit3141762fc0a5a35b5541ee183b1b7fe0672c41ae (patch)
tree6ccd41f9ad5ed8ffacfc74d5f7ce0ef26db63b65 /test
parentMove persistence test objects to test library (diff)
downloadilt-3141762fc0a5a35b5541ee183b1b7fe0672c41ae.tar.bz2
ilt-3141762fc0a5a35b5541ee183b1b7fe0672c41ae.tar.xz
ilt-3141762fc0a5a35b5541ee183b1b7fe0672c41ae.zip
Add a generic persistence perf test
Diffstat (limited to 'test')
-rw-r--r--test/Jamfile.jam4
-rw-r--r--test/perf-persistence.cpp23
2 files changed, 27 insertions, 0 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam
index e5781e1..e178573 100644
--- a/test/Jamfile.jam
+++ b/test/Jamfile.jam
@@ -55,6 +55,10 @@ run test-render.cpp : : : <library>test ;
run test-glContextBhvr.cpp ;
run test-assetFactory.cpp : -- : ../res/brush47.xml : <library>test ;
run perf-assetFactory.cpp : : : <library>benchmark <library>test ;
+run perf-persistence.cpp : : : <library>benchmark <library>test ;
compile test-static-enumDetails.cpp ;
compile test-static-stream_support.cpp ;
explicit perf-assetFactory ;
+explicit perf-persistence ;
+alias perf : perf-assetFactory perf-persistence ;
+explicit perf ;
diff --git a/test/perf-persistence.cpp b/test/perf-persistence.cpp
new file mode 100644
index 0000000..2e099bf
--- /dev/null
+++ b/test/perf-persistence.cpp
@@ -0,0 +1,23 @@
+#include "lib/jsonParse-persistence.h"
+#include "testMainWindow.h"
+#include "testStructures.h"
+#include <benchmark/benchmark.h>
+
+template<typename T>
+static void
+parse_load_object(benchmark::State & state, T &&, const char * path)
+{
+ for (auto _ : state) {
+ std::ifstream in {path};
+ benchmark::DoNotOptimize(Persistence::JsonParsePersistence {}.loadState<T>(in));
+ }
+}
+
+BENCHMARK_CAPTURE(parse_load_object, load_object, std::unique_ptr<TestObject> {}, FIXTURESDIR "json/load_object.json");
+BENCHMARK_CAPTURE(parse_load_object, nested, std::unique_ptr<TestObject> {}, FIXTURESDIR "json/nested.json");
+BENCHMARK_CAPTURE(parse_load_object, shared_ptr_diff, std::unique_ptr<SharedTestObject> {},
+ FIXTURESDIR "json/shared_ptr_diff.json");
+BENCHMARK_CAPTURE(parse_load_object, shared_ptr_same, std::unique_ptr<SharedTestObject> {},
+ FIXTURESDIR "json/shared_ptr_same.json");
+
+BENCHMARK_MAIN();