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 <string>
12#include <unordered_set>
13#include <utility>
14
15#include "associative_container_benchmarks.h"
16#include "benchmark/benchmark.h"
17
18template <class K>
19struct support::adapt_operations<std::unordered_set<K>> {
20 using ValueType = typename std::unordered_set<K>::value_type;
21 using KeyType = typename std::unordered_set<K>::key_type;
22 static ValueType value_from_key(KeyType const& k) { return k; }
23 static KeyType key_from_value(ValueType const& value) { return value; }
24
25 using InsertionResult = std::pair<typename std::unordered_set<K>::iterator, bool>;
26 static auto get_iterator(InsertionResult const& result) { return result.first; }
27};
28
29int main(int argc, char** argv) {
30 support::associative_container_benchmarks<std::unordered_set<int>>(container: "std::unordered_set<int>");
31 support::associative_container_benchmarks<std::unordered_set<std::string>>(container: "std::unordered_set<std::string>");
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/unordered_set.bench.cpp