[#227] netmap: Remove unnecessary unit tests

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/fyrchik/update-contracts
Leonard Lyubich 2022-06-15 22:04:54 +03:00 committed by LeL
parent d51a324147
commit e999fb00c3
1 changed files with 0 additions and 87 deletions

View File

@ -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)
}
}