提交 2994738e authored 作者: Thomas Mueller's avatar Thomas Mueller

Add metrics

上级 f9baefbb
......@@ -366,6 +366,32 @@ public class CacheLongKeyLIRS<V> {
return x;
}
/**
* Get the number of cache hits.
*
* @return the cache hits
*/
public long getHits() {
long x = 0;
for (Segment<V> s : segments) {
x += s.hits;
}
return x;
}
/**
* Get the number of cache misses.
*
* @return the cache misses
*/
public long getMisses() {
int x = 0;
for (Segment<V> s : segments) {
x += s.misses;
}
return x;
}
/**
* Get the number of resident entries.
*
......@@ -480,6 +506,16 @@ public class CacheLongKeyLIRS<V> {
*/
int queue2Size;
/**
* The number of cache hits.
*/
long hits;
/**
* The number of cache misses.
*/
long misses;
/**
* The map array. The size is always a power of 2.
*/
......@@ -579,6 +615,8 @@ public class CacheLongKeyLIRS<V> {
*/
Segment(Segment<V> old, int len) {
this(old.maxMemory, old.stackMoveDistance, len);
hits = old.hits;
misses = old.misses;
Entry<V> s = old.stack.stackPrev;
while (s != old.stack) {
Entry<V> e = copy(s);
......@@ -668,11 +706,13 @@ public class CacheLongKeyLIRS<V> {
Entry<V> e = find(key, hash);
if (e == null) {
// the entry was not found
misses++;
return null;
}
V value = e.value;
if (value == null) {
// it was a non-resident entry
misses++;
return null;
}
if (e.isHot()) {
......@@ -685,6 +725,7 @@ public class CacheLongKeyLIRS<V> {
} else {
access(key, hash);
}
hits++;
return value;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论