diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2016-03-25 21:11:33 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2016-03-27 19:12:37 +0000 |
| commit | 995fb0319eda217242fac8f2e11b576b7b7f79a9 (patch) | |
| tree | 14778a58ddfbd5e8057119ccd56e6479c7b87a6b /src/runtime/string_test.go | |
| parent | 4ffa5eb8764b9c811bff329e7d2e392dc1e8972c (diff) | |
| download | go-995fb0319eda217242fac8f2e11b576b7b7f79a9.tar.xz | |
cmd/compile: fix stringtoslicebytetmp optimization
Fixes #14973.
Change-Id: Iea68c9deca9429bde465c9ae05639209fe0ccf72
Reviewed-on: https://go-review.googlesource.com/21175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/string_test.go')
| -rw-r--r-- | src/runtime/string_test.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/runtime/string_test.go b/src/runtime/string_test.go index 292d5595e3..ee9709e87d 100644 --- a/src/runtime/string_test.go +++ b/src/runtime/string_test.go @@ -10,6 +10,10 @@ import ( "testing" ) +// Strings and slices that don't escape and fit into tmpBuf are stack allocated, +// which defeats using AllocsPerRun to test other optimizations. +const sizeNoStack = 100 + func BenchmarkCompareStringEqual(b *testing.B) { bytes := []byte("Hello Gophers!") s1, s2 := string(bytes), string(bytes) @@ -158,7 +162,7 @@ func TestGostringnocopy(t *testing.T) { } func TestCompareTempString(t *testing.T) { - s := "foo" + s := strings.Repeat("x", sizeNoStack) b := []byte(s) n := testing.AllocsPerRun(1000, func() { if string(b) != s { @@ -221,7 +225,7 @@ func TestIntStringAllocs(t *testing.T) { } func TestRangeStringCast(t *testing.T) { - s := "abc" + s := strings.Repeat("x", sizeNoStack) n := testing.AllocsPerRun(1000, func() { for i, c := range []byte(s) { if c != s[i] { |
