1
0
mirror of https://github.com/golang/go synced 2024-11-12 07:00:21 -07:00

runtime: benchmark for appending N bytes should not append N² bytes.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7420051
This commit is contained in:
Rémy Oudompheng 2013-03-02 21:11:05 +01:00
parent 5aacf43651
commit 1f74aa21d5

View File

@ -26,9 +26,7 @@ func benchmarkAppendBytes(b *testing.B, length int) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
x = x[0:0] x = x[0:0]
for j := 0; j < N; j++ { x = append(x, y...)
x = append(x, y...)
}
} }
} }
@ -58,9 +56,7 @@ func benchmarkAppendStr(b *testing.B, str string) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
x = x[0:0] x = x[0:0]
for j := 0; j < N; j++ { x = append(x, str...)
x = append(x, str...)
}
} }
} }