// bytesSent counts the bytes of application data sent.
// packetsSent counts packets.
- bytesSent int64
+ bytesSent int64
packetsSent int64
-
+
// activeCall is an atomic int32; the low bit is whether Close has
// been called. the rest of the bits are the number of goroutines
// in Conn.Write.
panic("unknown cipher type")
}
}
-
+
// Allow packet growth in arithmetic progression up to max.
pkt := c.packetsSent
c.packetsSent++
if pkt > 1000 {
return maxPlaintext // avoid overflow in multiply below
}
-
- n := payloadBytes * int(pkt + 1)
+
+ n := payloadBytes * int(pkt+1)
if n > maxPlaintext {
n = maxPlaintext
}
func BenchmarkThroughput(b *testing.B) {
for _, mode := range []string{"Max", "Dynamic"} {
- for size := 1; size <= 64; size<<=1{
+ for size := 1; size <= 64; size <<= 1 {
name := fmt.Sprintf("%sPacket/%dMB", mode, size)
b.Run(name, func(b *testing.B) {
throughput(b, int64(size<<20), mode == "Max")
t0 := time.Now()
wrote := 0
for wrote < len(p) {
- time.Sleep(100*time.Microsecond)
- allowed := int(time.Since(t0).Seconds() * float64(c.bps)) / 8
+ time.Sleep(100 * time.Microsecond)
+ allowed := int(time.Since(t0).Seconds()*float64(c.bps)) / 8
if allowed > len(p) {
allowed = len(p)
}
}
}
-
func BenchmarkLatency(b *testing.B) {
for _, mode := range []string{"Max", "Dynamic"} {
for _, kbps := range []int{200, 500, 1000, 2000, 5000} {