package main import ( "runtime" "strconv" "time" "gitee.com/wecisecode/util/logger" "github.com/willf/bloom" ) func main() { // 121 seconds , 25G //filter := bloom.NewWithEstimates(200000000, 0.0001) //126, 2.5G //filter := bloom.NewWithEstimates(20000000, 0.00001) //122, 2.5G //filter := bloom.NewWithEstimates(20000000, 0.000001) //153, 2.5G //filter := bloom.NewWithEstimates(20000000, 0.0000001) //156, 254m filter := bloom.NewWithEstimates(2000000, 0.0000001) for i := 0; i < 2000000; i++ { if i%10000 == 0 { logger.Info("set now ==>", i) } filter.Add([]byte("straaaa" + strconv.Itoa(i))) } st := time.Now().UnixNano() for i := 0; i < 150000; i++ { filter.Test([]byte("straaaa" + strconv.Itoa(i))) } ed := time.Now().UnixNano() logger.Info("diff ==>", (ed-st)/1e6) var mem runtime.MemStats runtime.ReadMemStats(&mem) logger.Infof("TotalAlloc = %v MiB", mem.TotalAlloc/1024/1024) time.Sleep(100 * time.Second) }