Skip to content

Commit 20de668

Browse files
committed
Add flat_multimap benchmarks
1 parent 4faf887 commit 20de668

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

libcxx/test/benchmarks/containers/associative/flat_map.bench.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// REQUIRES: std-at-least-c++26
1010

1111
#include <flat_map>
12-
#include <string>
1312
#include <utility>
1413

1514
#include "associative_container_benchmarks.h"
@@ -18,8 +17,8 @@
1817

1918
template <class K, class V>
2019
struct support::adapt_operations<std::flat_map<K, V>> {
21-
using ValueType = typename std::map<K, V>::value_type;
22-
using KeyType = typename std::map<K, V>::key_type;
20+
using ValueType = typename std::flat_map<K, V>::value_type;
21+
using KeyType = typename std::flat_map<K, V>::key_type;
2322
static ValueType value_from_key(KeyType const& k) { return {k, Generate<V>::arbitrary()}; }
2423
static KeyType key_from_value(ValueType const& value) { return value.first; }
2524

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
// REQUIRES: std-at-least-c++26
10+
11+
#include <flat_map>
12+
13+
#include "associative_container_benchmarks.h"
14+
#include "../../GenerateInput.h"
15+
#include "benchmark/benchmark.h"
16+
17+
template <class K, class V>
18+
struct support::adapt_operations<std::flat_multimap<K, V>> {
19+
using ValueType = typename std::flat_multimap<K, V>::value_type;
20+
using KeyType = typename std::flat_multimap<K, V>::key_type;
21+
static ValueType value_from_key(KeyType const& k) { return {k, Generate<V>::arbitrary()}; }
22+
static KeyType key_from_value(ValueType const& value) { return value.first; }
23+
24+
using InsertionResult = typename std::flat_multimap<K, V>::iterator;
25+
static auto get_iterator(InsertionResult const& result) { return result; }
26+
};
27+
28+
int main(int argc, char** argv) {
29+
support::associative_container_benchmarks<std::flat_multimap<int, int>>("std::flat_multimap<int, int>");
30+
31+
benchmark::Initialize(&argc, argv);
32+
benchmark::RunSpecifiedBenchmarks();
33+
benchmark::Shutdown();
34+
return 0;
35+
}

0 commit comments

Comments
 (0)