diff options
| author | Maxime Coste <maxime.coste@havok.com> | 2015-01-13 13:48:16 +0000 |
|---|---|---|
| committer | Maxime Coste <maxime.coste@havok.com> | 2015-01-13 13:48:16 +0000 |
| commit | beb3390334fc4e7071645c89018e45eaa81f47ba (patch) | |
| tree | 485ae729cd6a15f887a76880f09ee36c2cab589e /src/interned_string.cc | |
| parent | b9c4fc2d8c455991d1ffda250df5acacf5949a82 (diff) | |
Add interned string stats in debug command
Diffstat (limited to 'src/interned_string.cc')
| -rw-r--r-- | src/interned_string.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/interned_string.cc b/src/interned_string.cc index 3646e2f8..fb6898c0 100644 --- a/src/interned_string.cc +++ b/src/interned_string.cc @@ -1,8 +1,28 @@ #include "interned_string.hh" +#include "debug.hh" namespace Kakoune { +void StringRegistry::debug_stats() const +{ + write_debug("Interned Strings stats:"); + write_debug(" slots: " + to_string(m_storage.size()) + " allocated, " + to_string(m_free_slots.size()) + " free"); + size_t total_refcount = 0; + size_t total_size = 0; + size_t count = 0; + for (auto& st : m_storage) + { + if (st.refcount == 0) + continue; + total_refcount += st.refcount; + total_size += st.data.size(); + ++count; + } + write_debug(" data size: " + to_string(total_size) + ", mean: " + to_string((float)total_size/count)); + write_debug(" refcounts: " + to_string(total_refcount) + ", mean: " + to_string((float)total_refcount/count)); +} + InternedString StringRegistry::acquire(StringView str) { auto it = m_slot_map.find(str); |
