From ba02498576b634883bb9a0e48377f7383bc86289 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 7 Mar 2017 13:11:01 +0000 Subject: [PATCH] Expand a bit the hash map profiling code --- src/hash_map.cc | 17 ++++++++++++++--- src/hash_map.hh | 3 +-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/hash_map.cc b/src/hash_map.cc index 4220d17e..5799f87b 100644 --- a/src/hash_map.cc +++ b/src/hash_map.cc @@ -106,10 +106,21 @@ void do_profile(size_t count, StringView type) map.erase(dist(re)); auto after_remove = Clock::now(); - write_to_debug_buffer(format("{} ({}) -- inserts: {}ms, reads: {}ms, remove: {}ms", type, count, + int c = 0; + for (auto v : vec) + { + auto it = map.find(v); + if (it != map.end()) + ++c; + } + auto after_find = Clock::now(); + + write_to_debug_buffer(format("{} ({}) -- inserts: {}ms, reads: {}ms, remove: {}ms, find: {}ms ({})", type, count, std::chrono::duration_cast(after_insert - start).count(), std::chrono::duration_cast(after_read - after_insert).count(), - std::chrono::duration_cast(after_remove - after_read).count())); + std::chrono::duration_cast(after_remove - after_read).count(), + std::chrono::duration_cast(after_find - after_remove).count(), + c)); } void profile_hash_maps() @@ -117,7 +128,7 @@ void profile_hash_maps() for (auto i : { 1000, 10000, 100000, 1000000, 10000000 }) { do_profile>(i, "UnorderedMap"); - do_profile>(i, " HashMap "); + do_profile>(i, " HashMap"); } } diff --git a/src/hash_map.hh b/src/hash_map.hh index 47a50cd8..ab7b5e75 100644 --- a/src/hash_map.hh +++ b/src/hash_map.hh @@ -85,7 +85,6 @@ struct HashIndex void ordered_fix_entries(int index) { - // Fix entries index for (auto& entry : m_entries) { if (entry.index >= index) @@ -118,7 +117,7 @@ struct HashIndex private: size_t m_count = 0; - float m_max_fill_rate = 0.5f; + static constexpr float m_max_fill_rate = 0.9f; Vector m_entries; };