aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2016-05-27 19:47:55 -0700
committerRobert Griesemer <gri@golang.org>2016-06-01 00:06:09 +0000
commitfe62a9ee872d4f61a47cc4e8c7bc0fb67cc4ebb6 (patch)
tree78f655e9d88fee33b79d63f39e6fa641b0c6fbf3
parente106122200032cdf4f0a993cdd89c7531aaf8d75 (diff)
downloadgo-fe62a9ee872d4f61a47cc4e8c7bc0fb67cc4ebb6.tar.gz
go-fe62a9ee872d4f61a47cc4e8c7bc0fb67cc4ebb6.zip
crypto/tls: remove unused variable in benchmark code
This fixes `go test go/types`. https://golang.org/cl/23487/ introduced this code which contains two unused variables (declared and assigned to, but never read). cmd/compile doesn't report the error due open issue #8560 (the variables are assigned to in a closure), but go/types does. The build bot only runs go/types tests in -short mode (which doesn't typecheck the std lib), hence this doesn't show up on the dashboard either. We cannot call b.Fatal and friends in the goroutine. Communicating the error to the invoking function requires a channel or a mutex. Unless the channel/sycnhronized variable is tested in each iteration that follows, the iteration blocks if there's a failure. Testing in each iteration may affect benchmark times. One could use a time-out but that time depends on the underlying system. Panicking seems good enough in this unlikely case; better than hanging or affecting benchmark times. Change-Id: Idce1172da8058e580fa3b3e398825b0eb4316325 Reviewed-on: https://go-review.googlesource.com/23528 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/crypto/tls/tls_test.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/crypto/tls/tls_test.go b/src/crypto/tls/tls_test.go
index 47f02beeda..5b665bf532 100644
--- a/src/crypto/tls/tls_test.go
+++ b/src/crypto/tls/tls_test.go
@@ -481,20 +481,19 @@ func throughput(b *testing.B, totalBytes int64, dynamicRecordSizingDisabled bool
N := b.N
- var serr error
go func() {
for i := 0; i < N; i++ {
sconn, err := ln.Accept()
if err != nil {
- serr = err
- return
+ // panic rather than synchronize to avoid benchmark overhead
+ // (cannot call b.Fatal in goroutine)
+ panic(fmt.Errorf("accept: %v", err))
}
serverConfig := *testConfig
serverConfig.DynamicRecordSizingDisabled = dynamicRecordSizingDisabled
srv := Server(sconn, &serverConfig)
if err := srv.Handshake(); err != nil {
- serr = fmt.Errorf("handshake: %v", err)
- return
+ panic(fmt.Errorf("handshake: %v", err))
}
io.Copy(srv, srv)
}
@@ -570,20 +569,19 @@ func latency(b *testing.B, bps int, dynamicRecordSizingDisabled bool) {
N := b.N
- var serr error
go func() {
for i := 0; i < N; i++ {
sconn, err := ln.Accept()
if err != nil {
- serr = err
- return
+ // panic rather than synchronize to avoid benchmark overhead
+ // (cannot call b.Fatal in goroutine)
+ panic(fmt.Errorf("accept: %v", err))
}
serverConfig := *testConfig
serverConfig.DynamicRecordSizingDisabled = dynamicRecordSizingDisabled
srv := Server(&slowConn{sconn, bps}, &serverConfig)
if err := srv.Handshake(); err != nil {
- serr = fmt.Errorf("handshake: %v", err)
- return
+ panic(fmt.Errorf("handshake: %v", err))
}
io.Copy(srv, srv)
}