diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-03-07 13:11:01 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-03-07 14:01:01 +0000 |
| commit | ba02498576b634883bb9a0e48377f7383bc86289 (patch) | |
| tree | 84b37e5941f29162f344015a7947cf8c96e87321 /src/hash_map.cc | |
| parent | f3fdc2438362d6ec46c6e6989fc03c041dfde47a (diff) | |
Expand a bit the hash map profiling code
Diffstat (limited to 'src/hash_map.cc')
| -rw-r--r-- | src/hash_map.cc | 17 |
1 files changed, 14 insertions, 3 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"); } } |
