예제 #1
0
 public void BinaryFormatterBenchmark()
 {
     for (int i = 0; i < ItemsToInsert; i++)
     {
         var contains = _bloomFilter.Contains($"string-{i+1}");
     }
 }
 public void BinaryFormatterBenchmark()
 {
     foreach (var complexType in CreateComplexTypes())
     {
         var contains = _bloomFilter.Contains(complexType);
     }
 }
예제 #3
0
        public void Contains_WhenItemHasBeenAdded_ShouldReturnTrue()
        {
            var filter = new ScalableBloomFilter <int>(0.02);

            filter.Add(42);
            Assert.True(filter.Contains(42));
        }
 public void CheckIfContainsItem_ScalableBloomFilter()
 {
     for (int i = 0; i < ItemsToInsert; i++)
     {
         var contains = _regularScalableBloomFilter.Contains($"string-{i+1}");
     }
 }
예제 #5
0
        public void ScalableBloomFilterCorrectlyActsAsASet()
        {
            IBloomFilter <int> filter = new ScalableBloomFilter <int>(0.9, 10, 0.001);

            //10 cannot already be in the collection, so inserting it must succeed
            Assert.IsFalse(filter.Add(10));

            //10 is in the collection
            Assert.IsTrue(filter.Contains(10));

            //check a load more numbers
            for (int i = 0; i < 100; i++)
            {
                filter.Add(i);
                Assert.IsTrue(filter.Contains(i));
            }
        }
예제 #6
0
        public void ClearingScalabeBloomFilterResetsEverything()
        {
            ScalableBloomFilter <int> filter = new ScalableBloomFilter <int>(0.9, 1000, 0.001);

            //Add a load of numbers
            for (int i = 0; i < 100; i++)
            {
                filter.Add(i);
                Assert.IsTrue(filter.Contains(i));
            }
            Assert.AreEqual(100, filter.Count);

            filter.Clear();
            Assert.AreEqual(0, filter.Count);

            //Add them again
            for (int i = 0; i < 100; i++)
            {
                filter.Add(i);
                Assert.IsTrue(filter.Contains(i));
            }
            Assert.AreEqual(100, filter.Count);
        }
예제 #7
0
 public void Contains_WhenItemHasBeenAdded_AndFilterHasBeenSerializedAndUnserialized_ShouldReturnTrue()
 {
     using (var stream = new MemoryStream())
     {
         var filterOld = new ScalableBloomFilter <int>(0.02, ByteConverter);
         filterOld.Add(42);
         IFormatter formatter = new BinaryFormatter();
         formatter.Serialize(stream, filterOld);
         stream.Flush();
         stream.Position = 0;
         ScalableBloomFilter <int> filterNew = (ScalableBloomFilter <int>)formatter.Deserialize(stream);
         Assert.True(filterNew.Contains(42));
     }
 }
예제 #8
0
        public void AddItemsThenCount_ScalableBloomFilter()
        {
            var count = 0;

            for (var i = 0; i < ItemsToInsert; i++)
            {
                var s = $"string-{i + 1}";
                if (_scalableBloomFilter.Contains(s))
                {
                    continue;
                }
                count++;
                _scalableBloomFilter.Add(s);
            }

            var x = count;
        }
예제 #9
0
        public void Contains_WithFreshFilter_ShouldReturnFalse()
        {
            var filter = new ScalableBloomFilter <int>(0.02);

            Assert.False(filter.Contains(42));
        }
예제 #10
0
        public void ClearingScalabeBloomFilterResetsEverything()
        {
            ScalableBloomFilter<int> filter = new ScalableBloomFilter<int>(0.9, 1000, 0.001);

            //Add a load of numbers
            for (int i = 0; i < 100; i++)
            {
                filter.Add(i);
                Assert.IsTrue(filter.Contains(i));
            }
            Assert.AreEqual(100, filter.Count);

            filter.Clear();
            Assert.AreEqual(0, filter.Count);

            //Add them again
            for (int i = 0; i < 100; i++)
            {
                filter.Add(i);
                Assert.IsTrue(filter.Contains(i));
            }
            Assert.AreEqual(100, filter.Count);
        }
예제 #11
0
        public void ScalableBloomFilterCorrectlyActsAsASet()
        {
            IBloomFilter<int> filter = new ScalableBloomFilter<int>(0.9, 10, 0.001);

            //10 cannot already be in the collection, so inserting it must succeed
            Assert.IsFalse(filter.Add(10));

            //10 is in the collection
            Assert.IsTrue(filter.Contains(10));

            //check a load more numbers
            for (int i = 0; i < 100; i++)
            {
                filter.Add(i);
                Assert.IsTrue(filter.Contains(i));
            }
        }