mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
Improve benchmark to cover the usage (correct time difference)
This commit is contained in:
parent
5529ab3953
commit
55dce6f636
1 changed files with 7 additions and 15 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue