@Test public void shouldCollectIsTrueAfterWarmup() { DeterministicCollectorStrategy collector = new EveryXDeterministicCollectorStrategy(1000, 100); for (int i = 0; i < 1000; i++) { Assert.assertFalse(String.valueOf(i), collector.shouldCollect()); } Assert.assertTrue(collector.shouldCollect()); }
@Override public boolean shouldCollect() { boolean answer = false; int current = counter.getAndIncrement(); boolean isGreaterThanWarmupPeriod = hasWarmedUp.get() || current >= warmup; boolean isGreaterThanEveryX = current >= everyX; if (isGreaterThanWarmupPeriod && isGreaterThanEveryX) { hasWarmedUp.set(true); counter.set(0); answer = true; } LOG.debug("shouldCollect is '{}'", answer); return answer; }
EveryXDeterministicCollectorStrategy implements DeterministicCollectorStrategy { @Override public boolean shouldCollect() { boolean answer = false; int current = counter.getAndIncrement(); boolean isGreaterThanWarmupPeriod = hasWarmedUp.get() || current >= warmup; boolean isGreaterThanEveryX = current >= everyX; if (isGreaterThanWarmupPeriod && isGreaterThanEveryX) { hasWarmedUp.set(true); counter.set(0); answer = true; } LOG.debug("shouldCollect is '{}'", answer); return answer; } }
EveryXDeterministicCollectorStrategy implements DeterministicCollectorStrategy { @Override public boolean shouldCollect() { boolean answer = false; int current = counter.getAndIncrement(); boolean isGreaterThanWarmupPeriod = hasWarmedUp.get() || current >= warmup; boolean isGreaterThanEveryX = current >= everyX; if (isGreaterThanWarmupPeriod && isGreaterThanEveryX) { hasWarmedUp.set(true); counter.set(0); answer = true; } LOG.debug("shouldCollect is '{}'", answer); return answer; } EveryXDeterministicCollectorStrategy(int warmup, int everyX); }
EveryXDeterministicCollectorStrategy implements DeterministicCollectorStrategy { @Override public boolean shouldCollect() { boolean answer = false; int current = counter.getAndIncrement(); boolean isGreaterThanWarmupPeriod = hasWarmedUp.get() || current >= warmup; boolean isGreaterThanEveryX = current >= everyX; if (isGreaterThanWarmupPeriod && isGreaterThanEveryX) { hasWarmedUp.set(true); counter.set(0); answer = true; } LOG.debug("shouldCollect is '{}'", answer); return answer; } EveryXDeterministicCollectorStrategy(int warmup, int everyX); @Override boolean shouldCollect(); @Override String toString(); }
EveryXDeterministicCollectorStrategy implements DeterministicCollectorStrategy { @Override public boolean shouldCollect() { boolean answer = false; int current = counter.getAndIncrement(); boolean isGreaterThanWarmupPeriod = hasWarmedUp.get() || current >= warmup; boolean isGreaterThanEveryX = current >= everyX; if (isGreaterThanWarmupPeriod && isGreaterThanEveryX) { hasWarmedUp.set(true); counter.set(0); answer = true; } LOG.debug("shouldCollect is '{}'", answer); return answer; } EveryXDeterministicCollectorStrategy(int warmup, int everyX); @Override boolean shouldCollect(); @Override String toString();  }