From c26776fe48acc52304321d92a5dfcb3e60327c5b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 8 Jun 2017 18:25:38 -0700 Subject: [PATCH] gcs: add an extra benchmark for a filter with 100k items --- gcs/gcsbench_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gcs/gcsbench_test.go b/gcs/gcsbench_test.go index 8dc2602..2025181 100644 --- a/gcs/gcsbench_test.go +++ b/gcs/gcsbench_test.go @@ -55,6 +55,30 @@ func BenchmarkGCSFilterBuild50000(b *testing.B) { generatedFilter = localFilter } +// BenchmarkGCSFilterBuild benchmarks building a filter. +func BenchmarkGCSFilterBuild100000(b *testing.B) { + b.StopTimer() + var testKey [gcs.KeySize]byte + for i := 0; i < gcs.KeySize; i += 4 { + binary.BigEndian.PutUint32(testKey[i:], rand.Uint32()) + } + randFilterElems, genErr := genRandFilterElements(100000) + if err != nil { + b.Fatalf("unable to generate random item: %v", genErr) + } + b.StartTimer() + + var localFilter *gcs.Filter + for i := 0; i < b.N; i++ { + localFilter, err = gcs.BuildGCSFilter(P, key, + randFilterElems) + if err != nil { + b.Fatalf("unable to generate filter: %v", err) + } + } + generatedFilter = localFilter +} + var ( match bool )