File: attributes_processor_benchmark.cc

package info (click to toggle)
opentelemetry-cpp 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,744 kB
  • sloc: cpp: 79,029; sh: 1,640; makefile: 43; python: 31
file content (30 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (2)
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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <benchmark/benchmark.h>
#include <map>
#include <string>

#include "opentelemetry/common/key_value_iterable_view.h"
#include "opentelemetry/sdk/metrics/view/attributes_processor.h"

using namespace opentelemetry::sdk::metrics;
namespace
{
void BM_AttributseProcessorFilter(benchmark::State &state)
{
  std::map<std::string, int> attributes = {
      {"att1", 10}, {"attr1", 20}, {"attr3", 30}, {"attr4", 40}};
  FilteringAttributesProcessor attributes_processor(
      {{"attr2", true}, {"attr4", true}, {"attr6", true}});
  opentelemetry::common::KeyValueIterableView<std::map<std::string, int>> iterable(attributes);
  while (state.KeepRunning())
  {
    auto filtered_attributes = attributes_processor.process(iterable);
  }
}

BENCHMARK(BM_AttributseProcessorFilter);
}  // namespace

BENCHMARK_MAIN();