From beb3390334fc4e7071645c89018e45eaa81f47ba Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 13 Jan 2015 13:48:16 +0000 Subject: Add interned string stats in debug command --- src/interned_string.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/interned_string.cc') 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); -- cgit v1.2.3