From ac768b3e5cce05e463b8ff97243ff13f7119844a Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 15 Jan 2021 19:00:55 +0200 Subject: "about:debug" shows cache information IssueID #109 --- src/history.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/history.c') diff --git a/src/history.c b/src/history.c index 562c23bf..202549a9 100644 --- a/src/history.c +++ b/src/history.c @@ -86,6 +86,38 @@ iHistory *copy_History(const iHistory *d) { return copy; } +iString *debugInfo_History(const iHistory *d) { + iString *str = new_String(); + format_String(str, + "```\n" + "Idx | Size | SP%% | URL\n" + "----+---------+-----+-----\n"); + size_t totalSize = 0; + iConstForEach(Array, i, &d->recent) { + const iRecentUrl *item = i.value; + appendFormat_String( + str, " %2zu | ", size_Array(&d->recent) - index_ArrayConstIterator(&i) - 1); + if (item->cachedResponse) { + appendFormat_String(str, "%7zu", size_Block(&item->cachedResponse->body)); + totalSize += size_Block(&item->cachedResponse->body); + } + else { + appendFormat_String(str, " --"); + } + appendFormat_String(str, + " | %3d | %s\n", + iRound(100.0f * item->normScrollY), + cstr_String(&item->url)); + } + appendFormat_String(str, "\n```\n"); + appendFormat_String(str, + "Total cached data: %.3f MB\n" + "Navigation position: %zu\n\n", + totalSize / 1.0e6f, + d->recentPos); + return str; +} + void serialize_History(const iHistory *d, iStream *outs) { lock_Mutex(d->mtx); writeU16_Stream(outs, d->recentPos); -- cgit v1.2.3