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

Side by Side Diff: src/pkg/bufio/bufio_test.go

Issue 8819049: code review 8819049: bufio: make Reader buffer transient (Closed)
Patch Set: diff -r 43b3233f0b5b https://go.googlecode.com/hg/ Created 10 years, 10 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « src/pkg/bufio/bufio.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package bufio_test 5 package bufio_test
6 6
7 import ( 7 import (
8 . "bufio" 8 . "bufio"
9 "bytes" 9 "bytes"
10 "errors" 10 "errors"
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1076
1077 func BenchmarkWriterCopyNoReadFrom(b *testing.B) { 1077 func BenchmarkWriterCopyNoReadFrom(b *testing.B) {
1078 for i := 0; i < b.N; i++ { 1078 for i := 0; i < b.N; i++ {
1079 b.StopTimer() 1079 b.StopTimer()
1080 src := onlyReader{bytes.NewBuffer(make([]byte, 8192))} 1080 src := onlyReader{bytes.NewBuffer(make([]byte, 8192))}
1081 dst := onlyWriter{NewWriter(new(bytes.Buffer))} 1081 dst := onlyWriter{NewWriter(new(bytes.Buffer))}
1082 b.StartTimer() 1082 b.StartTimer()
1083 io.Copy(dst, src) 1083 io.Copy(dst, src)
1084 } 1084 }
1085 } 1085 }
1086
1087 func BenchmarkReaderEmpty(b *testing.B) {
1088 b.ReportAllocs()
1089 str := strings.Repeat("x", 16<<10)
1090 for i := 0; i < b.N; i++ {
1091 br := NewReader(strings.NewReader(str))
1092 n, err := io.Copy(ioutil.Discard, br)
1093 if err != nil {
1094 b.Fatal(err)
1095 }
1096 if n != int64(len(str)) {
1097 b.Fatal("wrong length")
1098 }
1099 }
1100 }
OLDNEW
« no previous file with comments | « src/pkg/bufio/bufio.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