attributemap_hash_benchmark.cc 661 B

123456789101112131415161718192021222324
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. #include <benchmark/benchmark.h>
  4. #include "opentelemetry/sdk/common/attribute_utils.h"
  5. #include "opentelemetry/sdk/common/attributemap_hash.h"
  6. using namespace opentelemetry::sdk::common;
  7. namespace
  8. {
  9. void BM_AttributeMapHash(benchmark::State &state)
  10. {
  11. OrderedAttributeMap map1 = {{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}, {"k4", "v4"},
  12. {"k5", true}, {"k6", 12}, {"k7", 12.209}};
  13. while (state.KeepRunning())
  14. {
  15. benchmark::DoNotOptimize(GetHashForAttributeMap(map1));
  16. }
  17. }
  18. BENCHMARK(BM_AttributeMapHash);
  19. } // namespace
  20. BENCHMARK_MAIN();