当前位置: 首页>>代码示例>>Java>>正文


Java SimpleStatsCounter类代码示例

本文整理汇总了Java中com.google.common.cache.AbstractCache.SimpleStatsCounter的典型用法代码示例。如果您正苦于以下问题:Java SimpleStatsCounter类的具体用法?Java SimpleStatsCounter怎么用?Java SimpleStatsCounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleStatsCounter类属于com.google.common.cache.AbstractCache包,在下文中一共展示了SimpleStatsCounter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stats

import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入依赖的package包/类
@Override
public CacheStats stats() {
  SimpleStatsCounter aggregator = new SimpleStatsCounter();
  aggregator.incrementBy(localCache.globalStatsCounter);
  for (Segment<K, V> segment : localCache.segments) {
    aggregator.incrementBy(segment.statsCounter);
  }
  return aggregator.snapshot();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:LocalCache.java

示例2: testEmptySimpleStats

import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入依赖的package包/类
public void testEmptySimpleStats() {
  StatsCounter counter = new SimpleStatsCounter();
  CacheStats stats = counter.snapshot();
  assertEquals(0, stats.requestCount());
  assertEquals(0, stats.hitCount());
  assertEquals(1.0, stats.hitRate());
  assertEquals(0, stats.missCount());
  assertEquals(0.0, stats.missRate());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadExceptionCount());
  assertEquals(0, stats.loadCount());
  assertEquals(0, stats.totalLoadTime());
  assertEquals(0.0, stats.averageLoadPenalty());
  assertEquals(0, stats.evictionCount());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:16,代码来源:AbstractCacheTest.java

示例3: testSingleSimpleStats

import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入依赖的package包/类
public void testSingleSimpleStats() {
  StatsCounter counter = new SimpleStatsCounter();
  for (int i = 0; i < 11; i++) {
    counter.recordHits(1);
  }
  for (int i = 0; i < 13; i++) {
    counter.recordLoadSuccess(i);
  }
  for (int i = 0; i < 17; i++) {
    counter.recordLoadException(i);
  }
  for (int i = 0; i < 23; i++) {
    counter.recordMisses(1);
  }
  for (int i = 0; i < 27; i++) {
    counter.recordEviction();
  }
  CacheStats stats = counter.snapshot();
  int requestCount = 11 + 23;
  assertEquals(requestCount, stats.requestCount());
  assertEquals(11, stats.hitCount());
  assertEquals(11.0 / requestCount, stats.hitRate());
  int missCount = 23;
  assertEquals(missCount, stats.missCount());
  assertEquals(((double) missCount) / requestCount, stats.missRate());
  assertEquals(13, stats.loadSuccessCount());
  assertEquals(17, stats.loadExceptionCount());
  assertEquals(13 + 17, stats.loadCount());
  assertEquals(214, stats.totalLoadTime());
  assertEquals(214.0 / (13 + 17), stats.averageLoadPenalty());
  assertEquals(27, stats.evictionCount());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:33,代码来源:AbstractCacheTest.java

示例4: stats

import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入依赖的package包/类
@Override
public CacheStats stats() {
               SimpleStatsCounter aggregator = new SimpleStatsCounter();
               aggregator.incrementBy(localCache.globalStatsCounter);
               for (Segment<K, V> segment : localCache.segments) {
    aggregator.incrementBy(segment.statsCounter);
               }
               return aggregator.snapshot();
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:10,代码来源:LocalCache.java

示例5: stats

import com.google.common.cache.AbstractCache.SimpleStatsCounter; //导入依赖的package包/类
@Override
public CacheStats stats() {
    SimpleStatsCounter aggregator = new SimpleStatsCounter();
    aggregator.incrementBy(localCache.globalStatsCounter);
    for (Segment<K, V> segment : localCache.segments) {
        aggregator.incrementBy(segment.statsCounter);
    }
    return aggregator.snapshot();
}
 
开发者ID:ketao1989,项目名称:cnGuava,代码行数:10,代码来源:LocalCache.java

示例6: 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());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:46,代码来源:AbstractCacheTest.java

示例7: 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());
}
 
开发者ID:google,项目名称:guava,代码行数:45,代码来源:AbstractCacheTest.java


注:本文中的com.google.common.cache.AbstractCache.SimpleStatsCounter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。