summaryrefslogtreecommitdiffstats
path: root/libgo/go/compress/lzw/writer_test.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-24 23:46:17 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-24 23:46:17 +0000
commitf97228863f84f4d7d87959ea40df40130f2ec912 (patch)
tree9319bca77115a32f6a0b5e8bcd651465b14c76da /libgo/go/compress/lzw/writer_test.go
parentd304b9e1af728d54ec16155c3d2116dc398c33c6 (diff)
downloadppe42-gcc-f97228863f84f4d7d87959ea40df40130f2ec912.tar.gz
ppe42-gcc-f97228863f84f4d7d87959ea40df40130f2ec912.zip
Update to current version of Go library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171427 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/compress/lzw/writer_test.go')
-rw-r--r--libgo/go/compress/lzw/writer_test.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/libgo/go/compress/lzw/writer_test.go b/libgo/go/compress/lzw/writer_test.go
index 715b974aa1e..2e0a8de0a87 100644
--- a/libgo/go/compress/lzw/writer_test.go
+++ b/libgo/go/compress/lzw/writer_test.go
@@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"os"
+ "runtime"
"testing"
)
@@ -99,13 +100,33 @@ func TestWriter(t *testing.T) {
}
}
-func BenchmarkEncoder(b *testing.B) {
+func benchmarkEncoder(b *testing.B, n int) {
b.StopTimer()
- buf, _ := ioutil.ReadFile("../testdata/e.txt")
+ b.SetBytes(int64(n))
+ buf0, _ := ioutil.ReadFile("../testdata/e.txt")
+ buf0 = buf0[:10000]
+ buf1 := make([]byte, n)
+ for i := 0; i < n; i += len(buf0) {
+ copy(buf1[i:], buf0)
+ }
+ buf0 = nil
+ runtime.GC()
b.StartTimer()
for i := 0; i < b.N; i++ {
w := NewWriter(devNull{}, LSB, 8)
- w.Write(buf)
+ w.Write(buf1)
w.Close()
}
}
+
+func BenchmarkEncoder1e4(b *testing.B) {
+ benchmarkEncoder(b, 1e4)
+}
+
+func BenchmarkEncoder1e5(b *testing.B) {
+ benchmarkEncoder(b, 1e5)
+}
+
+func BenchmarkEncoder1e6(b *testing.B) {
+ benchmarkEncoder(b, 1e6)
+}
OpenPOWER on IntegriCloud