Code example for MapMaker

Methods: makeMap

0
      CacheBuilder.newBuilder().recordStats().build(CacheLoader.from(IDENTITY));
  private final LoadingCache<Object, Object> loadingCacheNoStats =
      CacheBuilder.newBuilder().build(CacheLoader.from(IDENTITY));
 
  // Non-loading versions: 
  private final Map<Object, Object> map = new MapMaker().makeMap(); // Returns ConcurrentHashMap
  private final Cache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build();
  private final Cache<Object, Object> cacheNoStats = CacheBuilder.newBuilder().build();
 
  @Override 
  public void setUp() { 
    map.put(TEST_KEY, TEST_VALUE);
    cache.put(TEST_KEY, TEST_VALUE);
    cacheNoStats.put(TEST_KEY, TEST_VALUE);
  } 
 
  public void timeComputingMapMaker(int rep) {
    for (int i = 0; i < rep; i++) {
      computingMap.get(TEST_KEY);
    }