@@ -49,6 +49,8 @@ void CachingProxy::init(void)
4949// size and whatever other whizzy caching ideas we might want.
5050void CachingProxy::open (void )
5151{
52+ _nhits = 0 ;
53+ _nmisses = 0 ;
5254ReadThruProxy::open ();
5355}
5456
@@ -80,40 +82,55 @@ void CachingProxy::getAtom(const Handle& h)
8082{
8183CHECK_OPEN;
8284
83- if (h->haveValues ()) return ;
85+ if (h->haveValues ()) { _nhits++; return ; }
8486
87+ _nmisses ++;
8588ReadThruProxy::getAtom (h);
8689}
8790
8891void CachingProxy::fetchIncomingSet (AtomSpace* as, const Handle& h)
8992{
9093CHECK_OPEN;
91- if (0 < h->getIncomingSetSize (as)) return ;
94+ if (0 < h->getIncomingSetSize (as)) { _nhits++; return ; }
9295
96+ _nmisses ++;
9397ReadThruProxy::fetchIncomingSet (as, h);
9498}
9599
96100void CachingProxy::fetchIncomingByType (AtomSpace* as, const Handle& h, Type t)
97101{
98102CHECK_OPEN;
99- if (0 < h->getIncomingSetSizeByType (t, as)) return ;
103+ if (0 < h->getIncomingSetSizeByType (t, as)) { _nhits++; return ; }
100104
105+ _nmisses ++;
101106ReadThruProxy::fetchIncomingByType (as, h, t);
102107}
103108
104109void CachingProxy::loadValue (const Handle& atom, const Handle& key)
105110{
106111CHECK_OPEN;
107- if (nullptr != atom->getValue (key)) return ;
112+ if (nullptr != atom->getValue (key)) { _nhits++; return ; }
108113
114+ _nmisses ++;
109115ReadThruProxy::loadValue (atom, key);
110116}
111117
112118// We're just going to be unconditional, here.
113119void CachingProxy::loadType (AtomSpace* as, Type t)
114120{
115121CHECK_OPEN;
122+ _nmisses ++;
116123ReadThruProxy::loadType (as, t);
117124}
118125
126+ std::string CachingProxy::monitor (void )
127+ {
128+ std::string rpt;
129+ rpt += " Caching Proxy: " ;
130+ rpt += " hits: " + std::to_string (_nhits);
131+ rpt += " misses: " + std::to_string (_nmisses);
132+ rpt += " \n " ;
133+ return rpt;
134+ }
135+
119136DEFINE_NODE_FACTORY (CachingProxy, CACHING_PROXY_NODE)
0 commit comments