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); } }
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}"); } }
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)); } }
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); }
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)); } }
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; }
public void Contains_WithFreshFilter_ShouldReturnFalse() { var filter = new ScalableBloomFilter <int>(0.02); Assert.False(filter.Contains(42)); }
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); }
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)); } }