• Dmitriy Vyukov's avatar
    bufio: fix benchmarks behavior · 0ad2cd00
    Dmitriy Vyukov authored
    Currently the benchmarks lie to testing package by doing O(N)
    work under StopTimer. And that hidden O(N) actually consitutes
    the bulk of benchmark work (e.g includes GC per iteration).
    This behavior accounts for windows-amd64-race builder hangs.
    
    Before:
    BenchmarkReaderCopyOptimal-4	 1000000	      1861 ns/op
    BenchmarkReaderCopyUnoptimal-4	  500000	      3327 ns/op
    BenchmarkReaderCopyNoWriteTo-4	   50000	     34549 ns/op
    BenchmarkWriterCopyOptimal-4	  100000	     16849 ns/op
    BenchmarkWriterCopyUnoptimal-4	  500000	      3126 ns/op
    BenchmarkWriterCopyNoReadFrom-4	   50000	     34609 ns/op
    ok  	bufio	65.273s
    
    After:
    BenchmarkReaderCopyOptimal-4	10000000	       172 ns/op
    BenchmarkReaderCopyUnoptimal-4	10000000	       267 ns/op
    BenchmarkReaderCopyNoWriteTo-4	  100000	     22905 ns/op
    BenchmarkWriterCopyOptimal-4	10000000	       170 ns/op
    BenchmarkWriterCopyUnoptimal-4	10000000	       226 ns/op
    BenchmarkWriterCopyNoReadFrom-4	  100000	     20575 ns/op
    ok  	bufio	14.074s
    
    Note the change in total time.
    
    LGTM=alex.brainman, rsc
    R=golang-codereviews, alex.brainman, rsc
    CC=golang-codereviews
    https://golang.org/cl/51360046
    0ad2cd00
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...