blob: cf0be0d53d29db2398b2cb859d844fd7a41d62ab (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include <benchmark/benchmark.h>
#include <filesystem>
#include "testing-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;
}
class PerfIngestor : public WebStat::Ingestor {
using Ingestor::Ingestor;
void
log(int, const char *, ...) const override
{
}
};
void
doIngestFile(benchmark::State & state)
{
PerfIngestor ingestor {WebStat::getTestUtsName("perf-hostname"),
std::make_shared<WebStat::MockDBPool>("webstat"),
{
.userAgentAPI = {},
.maxBatchSize = static_cast<size_t>(state.range(0)),
}};
for (auto loop : state) {
WebStat::FilePtr logFile {fopen(TMP_LOG.c_str(), "r")};
ingestor.ingestLog(logFile.get());
}
}
}
BENCHMARK_RANGE(doIngestFile, 1, 1024)->Setup(setup);
BENCHMARK_MAIN();
|