Fix benchmark failing due to mainReadLoop returning io.EOF
This commit is contained in:
parent
8b6c26b912
commit
4eee1ba261
1
go.mod
1
go.mod
|
@ -20,6 +20,7 @@ require (
|
|||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/edsrzf/mmap-go v1.0.0
|
||||
github.com/elliotchance/orderedmap v1.2.2
|
||||
github.com/frankban/quicktest v1.9.0
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/google/btree v1.0.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -186,6 +186,8 @@ github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHj
|
|||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
|
||||
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
|
||||
github.com/frankban/quicktest v1.9.0 h1:jfEA+Psfr/pHsRJYPpHiNu7PGJnGctNxvTaM3K1EyXk=
|
||||
github.com/frankban/quicktest v1.9.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
|
@ -304,6 +306,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
|
|||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/anacrolix/missinggo/pubsub"
|
||||
"github.com/bradfitz/iter"
|
||||
"github.com/frankban/quicktest"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
|
@ -87,6 +88,7 @@ func (me *torrentStorage) WriteAt(b []byte, _ int64) (int, error) {
|
|||
}
|
||||
|
||||
func BenchmarkConnectionMainReadLoop(b *testing.B) {
|
||||
c := quicktest.New(b)
|
||||
cl := &Client{
|
||||
config: &ClientConfig{
|
||||
DownloadRateLimiter: unlimited,
|
||||
|
@ -140,8 +142,8 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) {
|
|||
ts.writeSem.Lock()
|
||||
}
|
||||
}()
|
||||
require.NoError(b, <-mrlErr)
|
||||
require.EqualValues(b, b.N, cn._stats.ChunksReadUseful.Int64())
|
||||
c.Assert([]error{nil, io.EOF}, quicktest.Contains, <-mrlErr)
|
||||
c.Assert(cn._stats.ChunksReadUseful.Int64(), quicktest.Equals, int64(b.N))
|
||||
}
|
||||
|
||||
func TestConnPexPeerFlags(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue