summaryrefslogtreecommitdiff
path: root/test/perf-ingest.cpp
blob: d05de170d181ce3ddc3827938b6f94b3e3e23169 (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
25
26
27
28
29
30
31
32
33
34
35
#include <benchmark/benchmark.h>
#include <filesystem>

#include "test-util.hpp"
#include <c++11Helpers.h>

#include <ingestor.hpp>

namespace {
	const std::filesystem::path TMP_LOG = std::format("/tmp/webstat-perf-{}.log", getpid());

	constexpr size_t LOG_LINES = 10000;
	const WebStat::LogFile LOG_FILE {TMP_LOG, LOG_LINES};

	void
	setup(const benchmark::State &)
	{
		static const WebStat::MockDB mockdb;
	}

	void
	doIngestFile(benchmark::State & state)
	{
		WebStat::Ingestor ingestor {
				WebStat::getTestUtsName("perf-hostname"), std::make_shared<WebStat::MockDBPool>("webstat")};
		for (auto loop : state) {
			WebStat::FilePtr logFile {fopen(TMP_LOG.c_str(), "r")};
			ingestor.ingestLog(logFile.get());
		}
	}
}

BENCHMARK(doIngestFile)->Setup(setup);

BENCHMARK_MAIN();