use of com.hazelcast.cardinality.CardinalityEstimator in project hazelcast-simulator by hazelcast.
the class CardinalityEstimatorTest method teardown.
@Teardown(global = true)
public void teardown() {
for (CardinalityEstimator estimator : estimators) {
estimator.destroy();
}
expectedCountMap.destroy();
totalThreadCount.destroy();
threadIdGenerator.destroy();
}
use of com.hazelcast.cardinality.CardinalityEstimator in project hazelcast-simulator by hazelcast.
the class CardinalityEstimatorTest method afterRun.
@AfterRun
public void afterRun(ThreadState state) {
// for each worker-thread we store the number of items it has produced for each estimator.
for (int k = 0; k < estimatorCount; k++) {
CardinalityEstimator estimator = estimators[k];
// the number of unique items produced is equal to the iteration. If items 0,10,20 are produced,
// then iteration is 3.
long iteration = state.iterations[k];
expectedCountMap.executeOnKey(estimator.getName(), new IncEntryProcessor(iteration));
}
}
use of com.hazelcast.cardinality.CardinalityEstimator in project hazelcast-simulator by hazelcast.
the class CardinalityEstimatorTest method verify.
@Verify(global = false)
public void verify() {
for (int k = 0; k < estimatorCount; k++) {
CardinalityEstimator estimator = estimators[k];
long expected = expectedCountMap.get(estimator.getName());
double maxError = (tolerancePercentage / 100d) * expected;
double minExpected = floor(expected - maxError);
double maxExpected = ceil(expected + maxError);
long actual = estimator.estimate();
long error = expected - actual;
double errorPercentage = (100d * error) / expected;
logger.info(estimator.getName() + " actual=" + actual + " expected=" + expected + " error=" + (errorPercentage) + "%s");
assertTrue("too few items counted, minExpected=" + minExpected + ", actual=" + actual + ", error=" + errorPercentage + "%", actual >= minExpected);
assertTrue("too many items counted, maxExpected=" + maxExpected + ", actual=" + actual + ", error=" + errorPercentage + "%", actual <= maxExpected);
}
}
Aggregations