14#include <benchmark/benchmark.h>
18static void BM_MemcmpBaseline(benchmark::State&
state)
25 metric =
"[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch";
26 for (
auto _ :
state) {
28 benchmark::DoNotOptimize(metric ==
"[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch");
30 state.SetBytesProcessed(
state.iterations() * metric.size());
35static void BM_RegexBaseline(benchmark::State&
state)
41 std::regex metricsRE(R
"regex(\[METRIC\] ([a-zA-Z0-9/_-]+),(0|1|2|4) ([0-9.a-zA-Z_/" <>()<$:-]+) ([0-9]+))regex", std::regex::optimize);
42 metric = "[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch";
46 char const* timestamp;
47 for (
auto _ :
state) {
48 std::cregex_token_iterator it(metric.data(), metric.data() + metric.length(), metricsRE, {1, 2, 3, 4});
55 timestamp = it->first;
57 state.SetBytesProcessed(
state.iterations() * metric.size());
61static void BM_ParseIntMetric(benchmark::State&
state)
68 metric =
"[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch";
69 for (
auto _ :
state) {
71 DeviceMetricsHelper::parseMetric(metric,
match);
73 state.SetBytesProcessed(
state.iterations() * metric.size());
78static void BM_ProcessIntMetric(benchmark::State&
state)
85 metric =
"[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch";
86 std::vector<std::string>
metrics{1000, metric};
88 for (
auto _ :
state) {
90 DeviceMetricsHelper::parseMetric(s,
match);
91 DeviceMetricsHelper::processMetric(
match, info);
99static void BM_ParseFloatMetric(benchmark::State&
state)
107 metric =
"[METRIC] key3,2 16.0 1789372894 hostname=test.cern.ch";
108 for (
auto _ :
state) {
109 DeviceMetricsHelper::parseMetric(metric,
match);
111 state.SetBytesProcessed(
state.iterations() * metric.size());
116static void BM_ProcessFloatMetric(benchmark::State&
state)
123 metric =
"[METRIC] key3,2 16.0 1789372894 hostname=test.cern.ch";
124 for (
auto _ :
state) {
125 DeviceMetricsHelper::parseMetric(metric,
match);
126 DeviceMetricsHelper::processMetric(
match, info);
128 state.SetBytesProcessed(
state.iterations() * metric.size());
133static void BM_ProcessStringMetric(benchmark::State&
state)
140 metric =
"[METRIC] key3,1 some_string 1789372895 hostname=test.cern.ch";
141 for (
auto _ :
state) {
143 DeviceMetricsHelper::parseMetric(metric,
match);
144 DeviceMetricsHelper::processMetric(
match, info);
146 state.SetBytesProcessed(
state.iterations() * metric.size());
151static void BM_ProcessMismatchedMetric(benchmark::State&
state)
158 metric =
"[METRICA] key3,1 some_string 1789372895 hostname=test.cern.ch";
159 for (
auto _ :
state) {
160 DeviceMetricsHelper::parseMetric(metric,
match);
162 state.SetBytesProcessed(
state.iterations() * metric.size());
BENCHMARK(BM_MemcmpBaseline)
bool match(const std::vector< std::string > &queries, const char *pattern)
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
Defining PrimaryVertex explicitly as messageable.
Temporary struct to hold a metric after it has been parsed.