Skip to content

Commit b852927

Browse files
ldionneIcohedron
authored andcommitted
[libc++] Implement generic associative container benchmarks (llvm#123663)
This patch implements generic associative container benchmarks for containers with unique keys. In doing so, it replaces the existing std::map benchmarks which were based on the cartesian product infrastructure and were too slow to execute. These new benchmarks aim to strike a balance between exhaustive coverage of all operations in the most interesting case, while executing fairly rapidly (~40s on my machine). This bumps the requirement for the map benchmarks from C++17 to C++20 because the common header that provides associative container benchmarks requires support for C++20 concepts.
1 parent 8474911 commit b852927

15 files changed

+870
-1426
lines changed

libcxx/test/benchmarks/GenerateInput.h

+5
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,18 @@ struct Generate<T> {
190190
static T arbitrary() { return 42; }
191191
static T cheap() { return 42; }
192192
static T expensive() { return 42; }
193+
static T random() { return getRandomInteger<T>(std::numeric_limits<T>::min(), std::numeric_limits<T>::max()); }
193194
};
194195

195196
template <>
196197
struct Generate<std::string> {
197198
static std::string arbitrary() { return "hello world"; }
198199
static std::string cheap() { return "small"; }
199200
static std::string expensive() { return std::string(256, 'x'); }
201+
static std::string random() {
202+
auto length = getRandomInteger<std::size_t>(1, 1024);
203+
return getRandomString(length);
204+
}
200205
};
201206

202207
#endif // BENCHMARK_GENERATE_INPUT_H

0 commit comments

Comments
 (0)