summaryrefslogtreecommitdiff
path: root/test/perf-persistence.cpp
blob: a39b0ba35bd409d471ca7ef41442ccca2947fe6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "lib/jsonParse-persistence.h"
#include "testStructures.h"
#include <benchmark/benchmark.h>

namespace {
	template<typename T>
	void
	parseLoadObject(benchmark::State & state, T &&, const char * path)
	{
		for (auto loop : state) {
			std::ifstream inStrm {path};
			benchmark::DoNotOptimize(Persistence::JsonParsePersistence {}.loadState<T>(inStrm));
		}
	}
}

BENCHMARK_CAPTURE(parseLoadObject, load_object, std::unique_ptr<TestObject> {}, FIXTURESDIR "json/load_object.json");
BENCHMARK_CAPTURE(parseLoadObject, nested, std::unique_ptr<TestObject> {}, FIXTURESDIR "json/nested.json");
BENCHMARK_CAPTURE(parseLoadObject, shared_ptr_diff, std::unique_ptr<SharedTestObject> {},
		FIXTURESDIR "json/shared_ptr_diff.json");
BENCHMARK_CAPTURE(parseLoadObject, shared_ptr_same, std::unique_ptr<SharedTestObject> {},
		FIXTURESDIR "json/shared_ptr_same.json");

BENCHMARK_MAIN();