Closed DanWillans closed 4 days ago
Your benchmark is extremely simplistic, you could basically just use an std::vector
instead. unordered maps are good at random stuff. Also, use this hash:
struct hash_a {
using is_avalanching = void;
[[nodiscard]] auto operator()(dan const& f) const noexcept -> uint64_t {
return ankerl::unordered_dense::hash<uint64_t>{}(f.id);
}
};
And use the same hash for both maps. Try a more real-live example than simply iterating a map that has inserted !
Hi,
I'm testing ankerl::unordered_dense::map against std::unordered_map for my custom type. When I profile std::unordered_map against ankerl::unordered_dense::map it's faster, am I using it incorrectly? As you can see in the code below for the std::hash specialisation I'm just returning the uint64_t because I can guarantee they're unique but in the custom_hash_unique_object_representation I'm instantiating wyhash.
If I just use a uint64_t ankerl is faster as the documentation and benchmarking shows.
Example code struct and hash for both std and ankerl.
Example code of usage