Ejemplo n.º 1
0
        public void TestHyperLogLog()
        {
            var           hll    = new HyperLogLog <int>();
            HashSet <int> actual = new ();

            var rand      = new Random();
            var tolerance = .05;

            for (var i = 0; i < 10000; i++)
            {
                var k = rand.Next(20000);
                hll.Add(k);
                actual.Add(k);
            }

            hll.Cardinality().Should()
            .BeGreaterOrEqualTo((int)(actual.Count * (1 - tolerance)))
            .And
            .BeLessOrEqualTo((int)(actual.Count * (1 + tolerance)));
        }