private static long estimateUniqueCount(int nValues) {
        SparseSketch sparse = new SparseSketch();
        while (sparse.size() < nValues) {
            sparse.aggregate(makeHash(random.nextInt()));
        }
        if (sparse.size() > HyperLogLog.SPARSE_SKETCH_CONVERSION_THRESHOLD) {
            NormalSketch normal = new NormalSketch();
            normal.aggregate(sparse.data());
            return estimator.estimateCount(normal);
        } else {
            return estimator.estimateCount(sparse);
        }
    }
This benchmarks performs a series of unique counting tests to analyse the HyperLogLog accuracy.
searchlib/src/test/java/com/yahoo/searchlib/aggregation/hll/HyperLogLogPrecisionBenchmark.java