From e999fb00c3ef75a3a69592c542317d99ff8ddff5 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 15 Jun 2022 22:04:54 +0300 Subject: [PATCH] [#227] netmap: Remove unnecessary unit tests Signed-off-by: Leonard Lyubich --- netmap/policy_test.go | 87 ------------------------------------------- 1 file changed, 87 deletions(-) diff --git a/netmap/policy_test.go b/netmap/policy_test.go index 1b5e385..47ec1d7 100644 --- a/netmap/policy_test.go +++ b/netmap/policy_test.go @@ -1,9 +1,7 @@ package netmap import ( - "math/rand" "strings" - "sync" "testing" "github.com/stretchr/testify/require" @@ -36,88 +34,3 @@ FILTER City EQ SPB AND SSD EQ true OR City EQ SPB AND Rating GE 5 AS SPBSSD`, require.Equal(t, testCase, b.String()) } } - -type cache struct { - mtx sync.RWMutex - - item map[string]struct{} -} - -func (x *cache) add(key string) { - x.mtx.Lock() - x.item[key] = struct{}{} - x.mtx.Unlock() -} - -func (x *cache) has(key string) bool { - x.mtx.RLock() - _, ok := x.item[key] - x.mtx.RUnlock() - - return ok -} - -func BenchmarkCache(b *testing.B) { - c := cache{ - item: make(map[string]struct{}), - } - - var key string - buf := make([]byte, 32) - - b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - b.StopTimer() - rand.Read(buf) - key = string(buf) - b.StartTimer() - - c.add(key) - c.has(key) - } -} - -type cacheP struct { - mtx *sync.RWMutex - - item map[string]struct{} -} - -func (x cacheP) add(key string) { - x.mtx.Lock() - x.item[key] = struct{}{} - x.mtx.Unlock() -} - -func (x cacheP) has(key string) bool { - x.mtx.RLock() - _, ok := x.item[key] - x.mtx.RUnlock() - - return ok -} - -func BenchmarkCacheP(b *testing.B) { - c := cacheP{ - mtx: &sync.RWMutex{}, - item: make(map[string]struct{}), - } - - var key string - buf := make([]byte, 32) - - b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - b.StopTimer() - rand.Read(buf) - key = string(buf) - b.StartTimer() - - c.add(key) - c.has(key) - } -}