mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Add large key tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package hash
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -77,90 +78,124 @@ func TestMurmur3(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Representative of small and medium subjects.
|
||||
var smlKey = []byte("foo")
|
||||
var medKey = []byte("apcera.continuum.router.foo.bar")
|
||||
var ch = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@$#%^&*()")
|
||||
|
||||
func sizedBytes(sz int) []byte {
|
||||
b := make([]byte, sz)
|
||||
for i := range b {
|
||||
b[i] = ch[rand.Intn(len(ch))]
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
var smlKey = sizedBytes(8)
|
||||
var medKey = sizedBytes(32)
|
||||
var lrgKey = sizedBytes(256)
|
||||
|
||||
func Benchmark_Bernstein_SmallKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Bernstein(smlKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Murmur3___SmallKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Murmur3(smlKey, M3Seed)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_FNV1A_____SmallKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
FNV1A(smlKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Meiyan____SmallKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Meiyan(smlKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Jesteress_SmallKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Jesteress(smlKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Yorikke___SmallKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Yorikke(smlKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Bernstein___MedKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Bernstein(medKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Murmur3_____MedKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Murmur3(medKey, M3Seed)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_FNV1A_______MedKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
FNV1A(medKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Meiyan______MedKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Meiyan(medKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Jesteress___MedKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Jesteress(medKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Yorikke_____MedKey(b *testing.B) {
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
Yorikke(medKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Bernstein___LrgKey(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Bernstein(lrgKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Murmur3_____LrgKey(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Murmur3(lrgKey, M3Seed)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_FNV1A_______LrgKey(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
FNV1A(lrgKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Meiyan______LrgKey(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Meiyan(lrgKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Jesteress___LrgKey(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Jesteress(lrgKey)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Yorikke_____LrgKey(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Yorikke(lrgKey)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user