Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(336)

Unified Diff: src/pkg/io/io_test.go

Issue 7206048: code review 7206048: io: reuse Copy buffers beween copies (Closed)
Patch Set: diff -r 606430dd2eca https://go.googlecode.com/hg/ Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/pkg/io/io.go ('K') | « src/pkg/io/io.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/io/io_test.go
===================================================================
--- a/src/pkg/io/io_test.go
+++ b/src/pkg/io/io_test.go
@@ -7,6 +7,7 @@
import (
"bytes"
. "io"
+ "io/ioutil"
"strings"
"testing"
)
@@ -235,3 +236,20 @@
}
}
}
+
+type neverending byte
+
+func (b neverending) Read(p []byte) (n int, err error) {
+ for i := 0; i < len(p); i++ {
+ p[i] = byte(b)
+ }
+ return len(p), nil
+}
+
+func BenchmarkCopy(b *testing.B) {
+ b.ReportAllocs()
+ var dst = struct{ Writer }{ioutil.Discard}
dfc 2013/01/24 00:06:20 nice
+ for i := 0; i < b.N; i++ {
+ Copy(dst, LimitReader(neverending('a'), 128<<10))
+ }
+}
« src/pkg/io/io.go ('K') | « src/pkg/io/io.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b