本文整理汇总了Java中com.google.common.cache.AbstractCache.SimpleStatsCounter.recordEviction方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleStatsCounter.recordEviction方法的具体用法?Java SimpleStatsCounter.recordEviction怎么用?Java SimpleStatsCounter.recordEviction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.cache.AbstractCache.SimpleStatsCounter
的用法示例。
在下文中一共展示了SimpleStatsCounter.recordEviction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleStatsIncrementBy
import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入方法依赖的package包/类
public void testSimpleStatsIncrementBy() {
long totalLoadTime = 0;
SimpleStatsCounter counter1 = new SimpleStatsCounter();
for (int i = 0; i < 11; i++) {
counter1.recordHits(1);
}
for (int i = 0; i < 13; i++) {
counter1.recordLoadSuccess(i);
totalLoadTime += i;
}
for (int i = 0; i < 17; i++) {
counter1.recordLoadException(i);
totalLoadTime += i;
}
for (int i = 0; i < 19; i++) {
counter1.recordMisses(1);
}
for (int i = 0; i < 23; i++) {
counter1.recordEviction();
}
SimpleStatsCounter counter2 = new SimpleStatsCounter();
for (int i = 0; i < 27; i++) {
counter2.recordHits(1);
}
for (int i = 0; i < 31; i++) {
counter2.recordLoadSuccess(i);
totalLoadTime += i;
}
for (int i = 0; i < 37; i++) {
counter2.recordLoadException(i);
totalLoadTime += i;
}
for (int i = 0; i < 41; i++) {
counter2.recordMisses(1);
}
for (int i = 0; i < 43; i++) {
counter2.recordEviction();
}
counter1.incrementBy(counter2);
assertEquals(new CacheStats(38, 60, 44, 54, totalLoadTime, 66),
counter1.snapshot());
}
示例2: testSimpleStatsIncrementBy
import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入方法依赖的package包/类
public void testSimpleStatsIncrementBy() {
long totalLoadTime = 0;
SimpleStatsCounter counter1 = new SimpleStatsCounter();
for (int i = 0; i < 11; i++) {
counter1.recordHits(1);
}
for (int i = 0; i < 13; i++) {
counter1.recordLoadSuccess(i);
totalLoadTime += i;
}
for (int i = 0; i < 17; i++) {
counter1.recordLoadException(i);
totalLoadTime += i;
}
for (int i = 0; i < 19; i++) {
counter1.recordMisses(1);
}
for (int i = 0; i < 23; i++) {
counter1.recordEviction();
}
SimpleStatsCounter counter2 = new SimpleStatsCounter();
for (int i = 0; i < 27; i++) {
counter2.recordHits(1);
}
for (int i = 0; i < 31; i++) {
counter2.recordLoadSuccess(i);
totalLoadTime += i;
}
for (int i = 0; i < 37; i++) {
counter2.recordLoadException(i);
totalLoadTime += i;
}
for (int i = 0; i < 41; i++) {
counter2.recordMisses(1);
}
for (int i = 0; i < 43; i++) {
counter2.recordEviction();
}
counter1.incrementBy(counter2);
assertEquals(new CacheStats(38, 60, 44, 54, totalLoadTime, 66), counter1.snapshot());
}