From 3141762fc0a5a35b5541ee183b1b7fe0672c41ae Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 5 Mar 2023 03:31:44 +0000 Subject: Add a generic persistence perf test --- test/perf-persistence.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/perf-persistence.cpp (limited to 'test/perf-persistence.cpp') 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 + +template +static void +parse_load_object(benchmark::State & state, T &&, const char * path) +{ + for (auto _ : state) { + std::ifstream in {path}; + benchmark::DoNotOptimize(Persistence::JsonParsePersistence {}.loadState(in)); + } +} + +BENCHMARK_CAPTURE(parse_load_object, load_object, std::unique_ptr {}, FIXTURESDIR "json/load_object.json"); +BENCHMARK_CAPTURE(parse_load_object, nested, std::unique_ptr {}, FIXTURESDIR "json/nested.json"); +BENCHMARK_CAPTURE(parse_load_object, shared_ptr_diff, std::unique_ptr {}, + FIXTURESDIR "json/shared_ptr_diff.json"); +BENCHMARK_CAPTURE(parse_load_object, shared_ptr_same, std::unique_ptr {}, + FIXTURESDIR "json/shared_ptr_same.json"); + +BENCHMARK_MAIN(); -- cgit v1.2.3