Search in sources :

Example 1 with CardinalityEstimator

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();
}
Also used : CardinalityEstimator(com.hazelcast.cardinality.CardinalityEstimator) Teardown(com.hazelcast.simulator.test.annotations.Teardown)

Example 2 with CardinalityEstimator

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));
    }
}
Also used : CardinalityEstimator(com.hazelcast.cardinality.CardinalityEstimator) AfterRun(com.hazelcast.simulator.test.annotations.AfterRun)

Example 3 with CardinalityEstimator

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);
    }
}
Also used : CardinalityEstimator(com.hazelcast.cardinality.CardinalityEstimator) Verify(com.hazelcast.simulator.test.annotations.Verify)

Aggregations

CardinalityEstimator (com.hazelcast.cardinality.CardinalityEstimator)3 AfterRun (com.hazelcast.simulator.test.annotations.AfterRun)1 Teardown (com.hazelcast.simulator.test.annotations.Teardown)1 Verify (com.hazelcast.simulator.test.annotations.Verify)1