Improve benchmark to cover the usage (correct time difference)

This commit is contained in:
ErikPelli 2022-06-12 20:26:44 +02:00 committed by Erik Pellizzon
parent 5529ab3953
commit 55dce6f636

View file

@ -504,22 +504,14 @@ func BenchmarkDecodeString(b *testing.B) {
}
}
func BenchmarkDecodeMapInitialize(b *testing.B) {
b.Run("new", func(b *testing.B) {
for i := 0; i < b.N; i++ {
e := new(Encoding)
copy(e.decodeMap[:], decodeMapInitialize)
func BenchmarkNewEncoding(b *testing.B) {
b.SetBytes(int64(len(Encoding{}.decodeMap)))
for i := 0; i < b.N; i++ {
e := NewEncoding(encodeStd)
for _, v := range e.decodeMap {
_ = v
}
})
b.Run("linear", func(b *testing.B) {
for i := 0; i < b.N; i++ {
e := new(Encoding)
for i := 0; i < len(e.decodeMap); i++ {
e.decodeMap[i] = 0xFF
}
}
})
}
}
func TestDecoderRaw(t *testing.T) {