summaryrefslogtreecommitdiff
path: root/test/perf-persistence.cpp
blob: 2e099bfb172dd6bf9b8ec8212e00115a31e8b823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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();