forked from quic-go/quic-go
Merge pull request #764 from lucas-clemente/fix-761
speed up the benchmark test by fetching random data only once
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/testdata"
|
"github.com/lucas-clemente/quic-go/testdata"
|
||||||
@@ -18,18 +17,15 @@ import (
|
|||||||
var _ = Describe("Benchmarks", func() {
|
var _ = Describe("Benchmarks", func() {
|
||||||
dataLen := 50 /* MB */ * (1 << 20)
|
dataLen := 50 /* MB */ * (1 << 20)
|
||||||
data := make([]byte, dataLen)
|
data := make([]byte, dataLen)
|
||||||
|
rand.Seed(GinkgoRandomSeed())
|
||||||
rand.Seed(time.Now().UnixNano())
|
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 %d", version), func() {
|
Context(fmt.Sprintf("with version %d", version), func() {
|
||||||
Measure("transferring a file", func(b Benchmarker) {
|
Measure("transferring a file", func(b Benchmarker) {
|
||||||
rand.Read(data) // no need to check for an error. math.Rand.Read never errors
|
|
||||||
|
|
||||||
var ln Listener
|
var ln Listener
|
||||||
|
|
||||||
serverAddr := make(chan net.Addr)
|
serverAddr := make(chan net.Addr)
|
||||||
handshakeChan := make(chan struct{})
|
handshakeChan := make(chan struct{})
|
||||||
// start the server
|
// start the server
|
||||||
|
|||||||
Reference in New Issue
Block a user