Skip to content

Commit 21cc567

Browse files
committed
address TODO in benchmarking.md
1 parent 352ff13 commit 21cc567

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

2-benchmarking/benchmarking.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,43 @@ func BenchmarkRead(b *testing.B) {
231231
}
232232
}
233233
```
234-
Here is an example funning
235-
DEMO: `go`test`-run=^$`-bench=.`bufio`
236-
237-
_Note:_ you can also use the `go`test`-benchmem` flag to do the same for _all_ benchmarks.
234+
Here is an example using the `bufio` package's benchmarks.
235+
```
236+
% go test -run=^$ -bench=. bufio
237+
goos: darwin
238+
goarch: amd64
239+
pkg: bufio
240+
BenchmarkReaderCopyOptimal-8 20000000 103 ns/op
241+
BenchmarkReaderCopyUnoptimal-8 10000000 159 ns/op
242+
BenchmarkReaderCopyNoWriteTo-8 500000 3644 ns/op
243+
BenchmarkReaderWriteToOptimal-8 5000000 344 ns/op
244+
BenchmarkWriterCopyOptimal-8 20000000 98.6 ns/op
245+
BenchmarkWriterCopyUnoptimal-8 10000000 131 ns/op
246+
BenchmarkWriterCopyNoReadFrom-8 300000 3955 ns/op
247+
BenchmarkReaderEmpty-8 2000000 789 ns/op 4224 B/op 3 allocs/op
248+
BenchmarkWriterEmpty-8 2000000 683 ns/op 4096 B/op 1 allocs/op
249+
BenchmarkWriterFlush-8 100000000 17.0 ns/op 0 B/op 0 allocs/op
250+
```
238251

239-
DEMO: `go`test`-run=^$`-bench=.`-benchmem`bufio`
252+
_Note:_ you can also use the `go test -benchmem` flag to the same for _all_ benchmarks.
253+
```
254+
% go test -run=^$ -bench=. -benchmem bufio
255+
goos: darwin
256+
goarch: amd64
257+
pkg: bufio
258+
BenchmarkReaderCopyOptimal-8 20000000 93.5 ns/op 16 B/op 1 allocs/op
259+
BenchmarkReaderCopyUnoptimal-8 10000000 155 ns/op 32 B/op 2 allocs/op
260+
BenchmarkReaderCopyNoWriteTo-8 500000 3238 ns/op 32800 B/op 3 allocs/op
261+
BenchmarkReaderWriteToOptimal-8 5000000 335 ns/op 16 B/op 1 allocs/op
262+
BenchmarkWriterCopyOptimal-8 20000000 96.7 ns/op 16 B/op 1 allocs/op
263+
BenchmarkWriterCopyUnoptimal-8 10000000 124 ns/op 32 B/op 2 allocs/op
264+
BenchmarkWriterCopyNoReadFrom-8 500000 3219 ns/op 32800 B/op 3 allocs/op
265+
BenchmarkReaderEmpty-8 2000000 748 ns/op 4224 B/op 3 allocs/op
266+
BenchmarkWriterEmpty-8 2000000 662 ns/op 4096 B/op 1 allocs/op
267+
BenchmarkWriterFlush-8 100000000 16.9 ns/op 0 B/op 0 allocs/op
268+
PASS
269+
ok bufio 20.366s
270+
```
240271

241272
### Watch out for compiler optimisations
242273

0 commit comments

Comments
 (0)