public void RedisClusterPerformance() { var n = 30000; var errRate = 0.01; var hashData = Helper.GenerateData(n); var configuration = "127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003,127.0.0.1:7004,127.0.0.1:7005"; var conn = ConnectionMultiplexer.Connect(configuration); foreach (var entry in conn.GetEndPoints()) { var server = conn.GetServer(entry); Console.WriteLine(server.EndPoint + " " + server.ServerType); } conn.Dispose(); var names = Enum.GetNames(typeof(HashMethod)); foreach (var name in names) { if (Enum.TryParse <HashMethod>(name, out var hm)) { var bf = FilterRedisBuilder.Build(configuration, "bftest", n, errRate, hm); bf.Clear(); Console.WriteLine($"=================== {name} Performance =================== "); Performance(hashData, bf); bf.Dispose(); } } }
public void BytesArrayTest(HashMethod hashMethod) { var bf = FilterRedisBuilder.Build("localhost", "BytesArrayTest", 10000, 0.01, hashMethod); var rng = RandomNumberGenerator.Create(); var len = 10; var list = new List <byte[]>(len); for (int i = 0; i < len; i++) { var data = new byte[1024]; rng.GetBytes(data); list.Add(data); } Assert.All(bf.Add(list), r => Assert.True(r)); Assert.All(bf.Contains(list), r => Assert.True(r)); Assert.True(bf.All(list)); bf.Clear(); Assert.All(bf.Contains(list), r => Assert.False(r)); Assert.False(bf.All(list)); }
public void RedisPerformance() { var n = 30000; var errRate = 0.01; var hashData = Helper.GenerateData(n); var warm_up = FilterRedisBuilder.Build("localhost", "RedisPerformance", n, errRate); warm_up.Clear(); Console.WriteLine($"=================== warm_up Performance =================== "); Performance(hashData, warm_up); var names = Enum.GetNames(typeof(HashMethod)); foreach (var name in names) { if (Enum.TryParse <HashMethod>(name, out var hm)) { var bf = FilterRedisBuilder.Build("localhost", "RedisPerformance", n, errRate, hm); bf.Clear(); Console.WriteLine($"=================== {name} Performance =================== "); Performance(hashData, bf); } } }
public void Setup() { var n = 1000000; var errRate = 0.01; data = Helper.GenerateBytes(DataSize); filter = FilterRedisBuilder.Build("localhost", "RedisBloomFilterTest", n, errRate, HashMethod.Murmur3KirschMitzenmacher); filter.Clear(); }
public void SampleInRedis() { var names = Enum.GetNames(typeof(HashMethod)); foreach (var name in names) { if (Enum.TryParse <HashMethod>(name, out var hm)) { var bf = FilterRedisBuilder.Build <string>("localhost", "bftest", 5000000, 0.001, hm); Sample(bf); } } }
public void NormalTest(HashMethod hashMethod) { var bf = FilterRedisBuilder.Build <string>("localhost", "NormalTest", 10000, 0.01, hashMethod); var len = 10; var array = new string[len]; for (int i = 0; i < len; i++) { array[i] = Utilitiy.GenerateString(10); } Assert.All(bf.Add(array), r => Assert.True(r)); Assert.All(bf.Contains(array), r => Assert.True(r)); Assert.True(bf.All(array)); bf.Clear(); Assert.All(bf.Contains(array), r => Assert.False(r)); Assert.False(bf.All(array)); }
public async Task NormalTestAsync(HashMethod hashMethod) { var bf = FilterRedisBuilder.Build("localhost", "NormalTestAsync", 10000, 0.01, hashMethod); var len = 10; var array = new string[len]; for (int i = 0; i < len; i++) { array[i] = Utilitiy.GenerateString(10); } Assert.All(await bf.AddAsync(array), r => Assert.True(r)); Assert.All(await bf.ContainsAsync(array), r => Assert.True(r)); Assert.True(await bf.AllAsync(array)); await bf.ClearAsync(); Assert.All(await bf.ContainsAsync(array), r => Assert.False(r)); Assert.False(await bf.AllAsync(array)); }
public void BuildTest() { var hashFun = new HashAlgorithms.HashCryptoMD5(); var config = ConfigurationOptions.Parse("localhost"); var conn = ConnectionMultiplexer.Connect(config); var operate = new RedisBitOperate(conn); buildTest(FilterRedisBuilder.Build <string>(config, "BuildTest", 10000)); buildTest(FilterRedisBuilder.Build <string>(config, "BuildTest", 10000, hashFun)); buildTest(FilterRedisBuilder.Build <string>(config, "BuildTest", 10000, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>(config, "BuildTest", 10000, 0.01)); buildTest(FilterRedisBuilder.Build <string>(config, "BuildTest", 10000, 0.01, hashFun)); buildTest(FilterRedisBuilder.Build <string>(config, "BuildTest", 10000, 0.01, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>("localhost", "BuildTest", 10000)); buildTest(FilterRedisBuilder.Build <string>("localhost", "BuildTest", 10000, hashFun)); buildTest(FilterRedisBuilder.Build <string>("localhost", "BuildTest", 10000, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>("localhost", "BuildTest", 10000, 0.01)); buildTest(FilterRedisBuilder.Build <string>("localhost", "BuildTest", 10000, 0.01, hashFun)); buildTest(FilterRedisBuilder.Build <string>("localhost", "BuildTest", 10000, 0.01, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>(conn, "BuildTest", 10000)); buildTest(FilterRedisBuilder.Build <string>(conn, "BuildTest", 10000, hashFun)); buildTest(FilterRedisBuilder.Build <string>(conn, "BuildTest", 10000, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>(conn, "BuildTest", 10000, 0.01)); buildTest(FilterRedisBuilder.Build <string>(conn, "BuildTest", 10000, 0.01, hashFun)); buildTest(FilterRedisBuilder.Build <string>(conn, "BuildTest", 10000, 0.01, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>(operate, "BuildTest", 10000)); buildTest(FilterRedisBuilder.Build <string>(operate, "BuildTest", 10000, hashFun)); buildTest(FilterRedisBuilder.Build <string>(operate, "BuildTest", 10000, HashMethod.Adler32)); buildTest(FilterRedisBuilder.Build <string>(operate, "BuildTest", 10000, 0.01)); buildTest(FilterRedisBuilder.Build <string>(operate, "BuildTest", 10000, 0.01, hashFun)); buildTest(FilterRedisBuilder.Build <string>(operate, "BuildTest", 10000, 0.01, HashMethod.Adler32)); conn.Dispose(); }
public async Task BuildTestAsync() { var hashFun = new HashAlgorithms.HashCryptoSHA256(); var config = ConfigurationOptions.Parse("localhost"); var conn = ConnectionMultiplexer.Connect(config); var operate = new RedisBitOperate(conn); await buildTestAsync(FilterRedisBuilder.Build(config, "BuildTest", 10000)); await buildTestAsync(FilterRedisBuilder.Build(config, "BuildTest", 10000, hashFun)); await buildTestAsync(FilterRedisBuilder.Build(config, "BuildTest", 10000, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build(config, "BuildTest", 10000, 0.01)); await buildTestAsync(FilterRedisBuilder.Build(config, "BuildTest", 10000, 0.01, hashFun)); await buildTestAsync(FilterRedisBuilder.Build(config, "BuildTest", 10000, 0.01, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build("localhost", "BuildTest", 10000)); await buildTestAsync(FilterRedisBuilder.Build("localhost", "BuildTest", 10000, hashFun)); await buildTestAsync(FilterRedisBuilder.Build("localhost", "BuildTest", 10000, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build("localhost", "BuildTest", 10000, 0.01)); await buildTestAsync(FilterRedisBuilder.Build("localhost", "BuildTest", 10000, 0.01, hashFun)); await buildTestAsync(FilterRedisBuilder.Build("localhost", "BuildTest", 10000, 0.01, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build(conn, "BuildTest", 10000)); await buildTestAsync(FilterRedisBuilder.Build(conn, "BuildTest", 10000, hashFun)); await buildTestAsync(FilterRedisBuilder.Build(conn, "BuildTest", 10000, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build(conn, "BuildTest", 10000, 0.01)); await buildTestAsync(FilterRedisBuilder.Build(conn, "BuildTest", 10000, 0.01, hashFun)); await buildTestAsync(FilterRedisBuilder.Build(conn, "BuildTest", 10000, 0.01, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build(operate, "BuildTest", 10000)); await buildTestAsync(FilterRedisBuilder.Build(operate, "BuildTest", 10000, hashFun)); await buildTestAsync(FilterRedisBuilder.Build(operate, "BuildTest", 10000, HashMethod.Adler32)); await buildTestAsync(FilterRedisBuilder.Build(operate, "BuildTest", 10000, 0.01)); await buildTestAsync(FilterRedisBuilder.Build(operate, "BuildTest", 10000, 0.01, hashFun)); await buildTestAsync(FilterRedisBuilder.Build(operate, "BuildTest", 10000, 0.01, HashMethod.Adler32)); conn.Dispose(); }
public async Task Performance() { var bf = FilterRedisBuilder.Build("localhost", "bftest", 100000, 0.01); var items = new List <string>(); var count = 50; var rndNum = new Random(Guid.NewGuid().GetHashCode()); for (int i = 0; i < count; i++) { items.Add(Helper.GenerateString(rndNum.Next(5, 30))); } await bf.AddAsync(items); var sw = Stopwatch.StartNew(); await bf.ContainsAsync(items); Console.WriteLine(sw.Elapsed); }
public void IntTest() { var config = ConfigurationOptions.Parse("localhost"); var bf = FilterRedisBuilder.Build <int>(config, "NormalTest", 10000, 0.01); var len = 10; var array = new int[len]; for (int i = 0; i < len; i++) { array[i] = i; } Assert.All(bf.Add(array), r => Assert.True(r)); Assert.All(bf.Contains(array), r => Assert.True(r)); Assert.True(bf.All(array)); bf.Clear(); Assert.All(bf.Contains(array), r => Assert.False(r)); Assert.False(bf.All(array)); }
public async Task IntTestAsync() { var config = ConfigurationOptions.Parse("localhost"); var bf = FilterRedisBuilder.Build(config, "IntTestAsync", 10000, 0.01); var len = 10; var array = new int[len]; for (int i = 0; i < len; i++) { array[i] = i; } Assert.All(await bf.AddAsync(array), r => Assert.True(r)); Assert.All(await bf.ContainsAsync(array), r => Assert.True(r)); Assert.True(await bf.AllAsync(array)); await bf.ClearAsync(); Assert.All(await bf.ContainsAsync(array), r => Assert.False(r)); Assert.False(await bf.AllAsync(array)); }