1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11#include <map>
12#include <string>
13#include <utility>
14
15#include "associative_container_benchmarks.h"
16#include "../../GenerateInput.h"
17#include "benchmark/benchmark.h"
18
19template <class K, class V>
20struct support::adapt_operations<std::map<K, V>> {
21 using ValueType = typename std::map<K, V>::value_type;
22 using KeyType = typename std::map<K, V>::key_type;
23 static ValueType value_from_key(KeyType const& k) { return {k, Generate<V>::arbitrary()}; }
24 static KeyType key_from_value(ValueType const& value) { return value.first; }
25
26 using InsertionResult = std::pair<typename std::map<K, V>::iterator, bool>;
27 static auto get_iterator(InsertionResult const& result) { return result.first; }
28};
29
30int main(int argc, char** argv) {
31 support::associative_container_benchmarks<std::map<int, int>>("std::map<int, int>");
32
33 benchmark::Initialize(&argc, argv);
34 benchmark::RunSpecifiedBenchmarks();
35 benchmark::Shutdown();
36 return 0;
37}
38

source code of libcxx/test/benchmarks/containers/associative/map.bench.cpp