Skip to content

Commit

Permalink
[libc++] Implement generic associative container benchmarks
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ldionne committed Jan 30, 2025
1 parent 439bef9 commit 8e1b692
Show file tree
Hide file tree
Showing 5 changed files with 597 additions and 932 deletions.
5 changes: 5 additions & 0 deletions libcxx/test/benchmarks/GenerateInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,18 @@ struct Generate<T> {
static T arbitrary() { return 42; }
static T cheap() { return 42; }
static T expensive() { return 42; }
static T random() { return getRandomInteger<T>(std::numeric_limits<T>::min(), std::numeric_limits<T>::max()); }
};

template <>
struct Generate<std::string> {
static std::string arbitrary() { return "hello world"; }
static std::string cheap() { return "small"; }
static std::string expensive() { return std::string(256, 'x'); }
static std::string random() {
auto length = getRandomInteger<std::size_t>(1, 1024);
return getRandomString(length);
}
};

#endif // BENCHMARK_GENERATE_INPUT_H
Loading

0 comments on commit 8e1b692

Please sign in to comment.