Extend wordcodec benchmarks

This commit is contained in:
Ethan Frey
2017-06-20 17:13:10 +02:00
parent daab270ff7
commit 1e15c8f75b
2 changed files with 68 additions and 30 deletions

View File

@ -178,33 +178,3 @@ func TestCheckTypoDetection(t *testing.T) {
}
}
}
func warmupCodec(bank string) *WordCodec {
codec, err := LoadCodec(bank)
if err != nil {
panic(err)
}
_, err = codec.GetIndex(codec.words[123])
if err != nil {
panic(err)
}
return codec
}
func BenchmarkWordGeneration(b *testing.B) {
// banks := []string{"english", "spanish", "japanese", "chinese_simplified"}
bank := "english"
codec := warmupCodec(bank)
b.ResetTimer()
numBytes := 32
data := cmn.RandBytes(numBytes)
for i := 1; i <= b.N; i++ {
_, err := codec.BytesToWords(data)
if err != nil {
panic(err)
}
}
}