forked from quic-go/quic-go
make the benchmark suite compatible with Go 1.13
Unfortunately, there doesn't seem to be a way to keep the samples flag.
This commit is contained in:
@@ -25,10 +25,10 @@ jobs:
|
|||||||
command: go version
|
command: go version
|
||||||
- run:
|
- run:
|
||||||
name: "Run benchmark tests"
|
name: "Run benchmark tests"
|
||||||
command: ginkgo -randomizeAllSpecs -trace benchmark -- -samples=1
|
command: ginkgo -randomizeAllSpecs -trace benchmark -- -size=10
|
||||||
- run:
|
- run:
|
||||||
name: "Run benchmark tests with race detector"
|
name: "Run benchmark tests with race detector"
|
||||||
command: ginkgo -race -randomizeAllSpecs -trace benchmark -- -samples=1 -size=10
|
command: ginkgo -race -randomizeAllSpecs -trace benchmark -- -size=5
|
||||||
- run:
|
- run:
|
||||||
name: "Run tools tests"
|
name: "Run tools tests"
|
||||||
command: ginkgo -race -r -v -randomizeAllSpecs -trace integrationtests/tools
|
command: ginkgo -race -r -v -randomizeAllSpecs -trace integrationtests/tools
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ fi
|
|||||||
|
|
||||||
if [ ${TESTMODE} == "integration" ]; then
|
if [ ${TESTMODE} == "integration" ]; then
|
||||||
# run benchmark tests
|
# run benchmark tests
|
||||||
ginkgo -randomizeAllSpecs -randomizeSuites -trace benchmark -- -samples=1
|
ginkgo -randomizeAllSpecs -randomizeSuites -trace benchmark -- -size=10
|
||||||
# run benchmark tests with the Go race detector
|
# run benchmark tests with the Go race detector
|
||||||
# The Go race detector only works on amd64.
|
# The Go race detector only works on amd64.
|
||||||
if [ ${TRAVIS_GOARCH} == 'amd64' ]; then
|
if [ ${TRAVIS_GOARCH} == 'amd64' ]; then
|
||||||
ginkgo -race -randomizeAllSpecs -randomizeSuites -trace benchmark -- -samples=1 -size=10
|
ginkgo -race -randomizeAllSpecs -randomizeSuites -trace benchmark -- -size=5
|
||||||
fi
|
fi
|
||||||
# run integration tests
|
# run integration tests
|
||||||
ginkgo -r -v -randomizeAllSpecs -randomizeSuites -trace integrationtests
|
ginkgo -r -v -randomizeAllSpecs -randomizeSuites -trace integrationtests
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ install:
|
|||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- ginkgo -r -v -randomizeAllSpecs -randomizeSuites -trace -skipPackage benchmark,integrationtests
|
- ginkgo -r -v -randomizeAllSpecs -randomizeSuites -trace -skipPackage benchmark,integrationtests
|
||||||
- ginkgo -randomizeAllSpecs -randomizeSuites -trace benchmark -- -samples=1
|
- ginkgo -randomizeAllSpecs -randomizeSuites -trace benchmark -- -size=10
|
||||||
|
|
||||||
test: off
|
test: off
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package benchmark
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@@ -16,11 +17,14 @@ func TestBenchmark(t *testing.T) {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
size int // file size in MB, will be read from flags
|
size int // file size in MB, will be read from flags
|
||||||
samples int // number of samples for Measure, will be read from flags
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.IntVar(&size, "size", 50, "data length (in MB)")
|
flag.IntVar(&size, "size", 50, "data length (in MB)")
|
||||||
flag.IntVar(&samples, "samples", 6, "number of samples")
|
|
||||||
flag.Parse()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ = BeforeSuite(func() {
|
||||||
|
rand.Seed(GinkgoRandomSeed())
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
})
|
||||||
|
|||||||
@@ -13,22 +13,26 @@ import (
|
|||||||
_ "github.com/lucas-clemente/quic-go/integrationtests/tools/testlog"
|
_ "github.com/lucas-clemente/quic-go/integrationtests/tools/testlog"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/testdata"
|
"github.com/lucas-clemente/quic-go/internal/testdata"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
var _ = Describe("Benchmarks", func() {
|
var _ = Describe("Benchmarks", func() {
|
||||||
dataLen := size * /* MB */ 1e6
|
|
||||||
data := make([]byte, dataLen)
|
|
||||||
rand.Seed(GinkgoRandomSeed())
|
|
||||||
rand.Read(data) // no need to check for an error. math.Rand.Read never errors
|
|
||||||
|
|
||||||
for i := range protocol.SupportedVersions {
|
for i := range protocol.SupportedVersions {
|
||||||
version := protocol.SupportedVersions[i]
|
version := protocol.SupportedVersions[i]
|
||||||
|
|
||||||
Context(fmt.Sprintf("with version %s", version), func() {
|
Context(fmt.Sprintf("with version %s", version), func() {
|
||||||
Measure(fmt.Sprintf("transferring a %d MB file", size), func(b Benchmarker) {
|
var data []byte
|
||||||
|
var dataLen int
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
dataLen = size * /* MB */ 1e6
|
||||||
|
data = make([]byte, dataLen)
|
||||||
|
rand.Read(data) // no need to check for an error. math.Rand.Read never errors
|
||||||
|
})
|
||||||
|
|
||||||
|
Measure("transferring a file", func(b Benchmarker) {
|
||||||
var ln quic.Listener
|
var ln quic.Listener
|
||||||
serverAddr := make(chan net.Addr)
|
serverAddr := make(chan net.Addr)
|
||||||
handshakeChan := make(chan struct{})
|
handshakeChan := make(chan struct{})
|
||||||
@@ -83,8 +87,7 @@ func init() {
|
|||||||
|
|
||||||
ln.Close()
|
ln.Close()
|
||||||
sess.Close()
|
sess.Close()
|
||||||
}, samples)
|
}, 3)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user