summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-03-07 13:11:01 +0000
committerMaxime Coste <mawww@kakoune.org>2017-03-07 14:01:01 +0000
commitba02498576b634883bb9a0e48377f7383bc86289 (patch)
tree84b37e5941f29162f344015a7947cf8c96e87321 /src
parentf3fdc2438362d6ec46c6e6989fc03c041dfde47a (diff)
Expand a bit the hash map profiling code
Diffstat (limited to 'src')
-rw-r--r--src/hash_map.cc17
-rw-r--r--src/hash_map.hh3
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<std::chrono::milliseconds>(after_insert - start).count(),
std::chrono::duration_cast<std::chrono::milliseconds>(after_read - after_insert).count(),
- std::chrono::duration_cast<std::chrono::milliseconds>(after_remove - after_read).count()));
+ std::chrono::duration_cast<std::chrono::milliseconds>(after_remove - after_read).count(),
+ std::chrono::duration_cast<std::chrono::milliseconds>(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<std::unordered_map<size_t, size_t>>(i, "UnorderedMap");
- do_profile<HashMap<size_t, size_t>>(i, " HashMap ");
+ do_profile<HashMap<size_t, size_t>>(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<Entry, domain> m_entries;
};