bytes: don't compact Buffer so aggressively

benchmark                           old ns/op    new ns/op    delta
BenchmarkBufferNotEmptyWriteRead       848416       819983   -3.35%

Update #5154

R=golang-dev, gri, robryk
CC=golang-dev
https://golang.org/cl/8173043
This commit is contained in:
Brad Fitzpatrick 2013-03-29 13:49:14 -07:00
parent 994f59666f
commit 43e38d5def
2 changed files with 9 additions and 5 deletions

View file

@ -490,8 +490,10 @@ func TestBufferGrowth(t *testing.T) {
}
}
cap1 := b.Cap()
if cap1 > cap0 {
t.Errorf("buffer cap = %d; too big", cap1)
// (*Buffer).grow allows for 2x capacity slop before sliding,
// so set our error threshold at 3x.
if cap1 > cap0*3 {
t.Errorf("buffer cap = %d; too big (grew from %d)", cap1, cap0)
}
}