diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 21:54:22 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 21:54:22 +0000 |
commit | af92e385667da3fc91ac7f9f0867a56c111110b8 (patch) | |
tree | c8e8990a2197e33f6fe50a28a16714aafe982102 /libgo/go/fmt | |
parent | df1304ee03f41aed179545d1e8b4684cfd22bbdf (diff) | |
download | gcc-af92e385667da3fc91ac7f9f0867a56c111110b8.tar.gz |
libgo: Update to weekly.2012-01-20.
From-SVN: r183540
Diffstat (limited to 'libgo/go/fmt')
-rw-r--r-- | libgo/go/fmt/fmt_test.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libgo/go/fmt/fmt_test.go b/libgo/go/fmt/fmt_test.go index beb410fa117..504194ce467 100644 --- a/libgo/go/fmt/fmt_test.go +++ b/libgo/go/fmt/fmt_test.go @@ -508,27 +508,28 @@ func BenchmarkSprintfFloat(b *testing.B) { var mallocBuf bytes.Buffer +// gccgo numbers are different because gccgo does not have escape +// analysis yet. var mallocTest = []struct { count int desc string fn func() }{ - {0, `Sprintf("")`, func() { Sprintf("") }}, - {1, `Sprintf("xxx")`, func() { Sprintf("xxx") }}, - {1, `Sprintf("%x")`, func() { Sprintf("%x", 7) }}, - {2, `Sprintf("%s")`, func() { Sprintf("%s", "hello") }}, - {1, `Sprintf("%x %x")`, func() { Sprintf("%x %x", 7, 112) }}, - {1, `Sprintf("%g")`, func() { Sprintf("%g", 3.14159) }}, - {0, `Fprintf(buf, "%x %x %x")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%x %x %x", 7, 8, 9) }}, - {1, `Fprintf(buf, "%s")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%s", "hello") }}, + {5, `Sprintf("")`, func() { Sprintf("") }}, + {5, `Sprintf("xxx")`, func() { Sprintf("xxx") }}, + {5, `Sprintf("%x")`, func() { Sprintf("%x", 7) }}, + {5, `Sprintf("%s")`, func() { Sprintf("%s", "hello") }}, + {5, `Sprintf("%x %x")`, func() { Sprintf("%x %x", 7, 112) }}, + // For %g we use a float32, not float64, to guarantee passing the argument + // does not need to allocate memory to store the result in a pointer-sized word. + {20, `Sprintf("%g")`, func() { Sprintf("%g", float32(3.14159)) }}, + {5, `Fprintf(buf, "%x %x %x")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%x %x %x", 7, 8, 9) }}, + {5, `Fprintf(buf, "%s")`, func() { mallocBuf.Reset(); Fprintf(&mallocBuf, "%s", "hello") }}, } var _ bytes.Buffer func TestCountMallocs(t *testing.T) { - if testing.Short() { - return - } for _, mt := range mallocTest { const N = 100 runtime.UpdateMemStats() @@ -538,7 +539,7 @@ func TestCountMallocs(t *testing.T) { } runtime.UpdateMemStats() mallocs += runtime.MemStats.Mallocs - if mallocs/N != uint64(mt.count) { + if mallocs/N > uint64(mt.count) { t.Errorf("%s: expected %d mallocs, got %d", mt.desc, mt.count, mallocs/N) } } |