Skip to content

Commit bdedbeb

Browse files
nephrosnephros
authored andcommitted
Hotcache: Implement a simpler stats method
1 parent b0c5479 commit bdedbeb

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/bin/patchmanager-daemon/patchmanagerobject.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,6 +3075,24 @@ void PatchManagerFilter::setup()
30753075
}
30763076
}
30773077

3078-
QList<QPair<QString, QVariant>> PatchManagerFilter::stats() const
3079-
{
3078+
//QList<QPair<QString, QVariant>> PatchManagerFilter::stats() const
3079+
QString PatchManagerFilter::stats() const
3080+
{
3081+
QStringList topTen;
3082+
const int ttmax = qEnvironmentVariableIsSet("PM_DEBUG_HOTCACHE") ? size() : 10;
3083+
foreach(const QString &key, keys() ) {
3084+
topTen << key;
3085+
if (topTen.size() >= ttmax)
3086+
break;
3087+
}
3088+
3089+
//QList<QPair<QString, QVariant>> list;
3090+
QTextStream list;
3091+
list << "Filter Stats:"
3092+
<< "\n==========================="
3093+
<< "\n Hotcache entries:: .............." << size()
3094+
<< "\n Hotcache cost: .................." << totalCost() << "/" << maxCost()
3095+
<< "\n Hotcache top entries: ..........." << "\n " << topTen.join("\n ")
3096+
<< "\n===========================";
3097+
return list.readAll();
30803098
}

src/bin/patchmanager-daemon/patchmanagerobject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class PatchManagerFilter : public QObject, public QCache<QString, QObject>
104104
unsigned int hits() const { return m_hits; };
105105
unsigned int misses() const { return m_misses; };
106106

107-
QList<QPair<QString, QVariant>> stats() const;
107+
//QList<QPair<QString, QVariant>> stats() const;
108+
QString stats() const;
108109

109110
signals:
110111
void activeChanged(bool);

0 commit comments

Comments
 (0)