@Test
  public void testAutoCalcFixedOverhead() throws InterruptedException {
    List<Class<?>> classList = Arrays.asList(HFileContext.class, HRegion.class, BlockCacheKey.class,
      HFileBlock.class, HStore.class, LruBlockCache.class, StoreContext.class);
    for (int i = 0; i < 10; i++) {
      // warm up
      calcFixedOverhead(classList);
    }
    long startNs = System.nanoTime();
    long overhead = 0;
    for (int i = 0; i < 100; i++) {
      overhead += calcFixedOverhead(classList);
    }
    long costNs = System.nanoTime() - startNs;
    LOG.info("overhead = {}, cost {} ns", overhead, costNs);
    // the single computation cost should be less than 5ms
    assertThat(costNs, lessThan(TimeUnit.MILLISECONDS.toNanos(5) * classList.size() * 100));
  }
Testing the classes that implements HeapSize and are a part of 0.20. Some are not tested here
for example BlockIndex which is tested in TestHFile since it is a non public class
hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java