mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 19:41:05 +01:00
Add a build of boost_unordered for benchmarking. (#4045)
This uses a header-only extraction of the Boost unordered hashtable project to allow a trivial Bazel build and for us to benchmark against it effectively.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include <boost/unordered/unordered_flat_map.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
@@ -133,6 +134,7 @@ struct MapWrapperImpl<Map<KT, VT, MinSmallSize>> {
|
||||
enum class MapOverride : uint8_t {
|
||||
None,
|
||||
Abseil,
|
||||
Boost,
|
||||
LLVM,
|
||||
LLVMAndCarbonHash,
|
||||
};
|
||||
@@ -147,6 +149,10 @@ template <typename KeyT, typename ValueT, int MinSmallSize>
|
||||
struct MapWrapperOverride<Map<KeyT, ValueT, MinSmallSize>, MapOverride::Abseil>
|
||||
: MapWrapperImpl<absl::flat_hash_map<KeyT, ValueT>> {};
|
||||
|
||||
template <typename KeyT, typename ValueT, int MinSmallSize>
|
||||
struct MapWrapperOverride<Map<KeyT, ValueT, MinSmallSize>, MapOverride::Boost>
|
||||
: MapWrapperImpl<boost::unordered::unordered_flat_map<KeyT, ValueT>> {};
|
||||
|
||||
template <typename KeyT, typename ValueT, int MinSmallSize>
|
||||
struct MapWrapperOverride<Map<KeyT, ValueT, MinSmallSize>, MapOverride::LLVM>
|
||||
: MapWrapperImpl<llvm::DenseMap<KeyT, ValueT>> {};
|
||||
@@ -170,10 +176,11 @@ auto ReportMetrics(const MapWrapper<MapT>& m_wrapper, benchmark::State& state)
|
||||
}
|
||||
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses): Parentheses are incorrect here.
|
||||
#define MAP_BENCHMARK_ONE_OP_SIZE(NAME, APPLY, KT, VT) \
|
||||
BENCHMARK(NAME<Map<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<absl::flat_hash_map<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<llvm::DenseMap<KT, VT>>)->Apply(APPLY); \
|
||||
#define MAP_BENCHMARK_ONE_OP_SIZE(NAME, APPLY, KT, VT) \
|
||||
BENCHMARK(NAME<Map<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<absl::flat_hash_map<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<boost::unordered::unordered_flat_map<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<llvm::DenseMap<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<llvm::DenseMap<KT, VT, CarbonHashDI<KT>>>)->Apply(APPLY)
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
@@ -407,6 +414,8 @@ MAP_BENCHMARK_ONE_OP(BM_MapEraseUpdateHit, HitArgs);
|
||||
#define MAP_BENCHMARK_OP_SEQ_SIZE(NAME, KT, VT) \
|
||||
BENCHMARK(NAME<Map<KT, VT>>)->Apply(SizeArgs); \
|
||||
BENCHMARK(NAME<absl::flat_hash_map<KT, VT>>)->Apply(SizeArgs); \
|
||||
BENCHMARK(NAME<boost::unordered::unordered_flat_map<KT, VT>>) \
|
||||
->Apply(SizeArgs); \
|
||||
BENCHMARK(NAME<llvm::DenseMap<KT, VT>>)->Apply(APPLY); \
|
||||
BENCHMARK(NAME<llvm::DenseMap<KT, VT, CarbonHashDI<KT>>>)->Apply(SizeArgs)
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
Reference in New Issue
Block a user