Commit 13393fb6 authored by Mikio Hara's avatar Mikio Hara

net: add TCP over IPv6 benchmarks

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7433044
parent 3d50aaf4
...@@ -11,23 +11,51 @@ import ( ...@@ -11,23 +11,51 @@ import (
"time" "time"
) )
func BenchmarkTCPOneShot(b *testing.B) { func BenchmarkTCP4OneShot(b *testing.B) {
benchmarkTCP(b, false, false) benchmarkTCP(b, false, false, "127.0.0.1:0")
} }
func BenchmarkTCPOneShotTimeout(b *testing.B) { func BenchmarkTCP4OneShotTimeout(b *testing.B) {
benchmarkTCP(b, false, true) benchmarkTCP(b, false, true, "127.0.0.1:0")
} }
func BenchmarkTCPPersistent(b *testing.B) { func BenchmarkTCP4Persistent(b *testing.B) {
benchmarkTCP(b, true, false) benchmarkTCP(b, true, false, "127.0.0.1:0")
} }
func BenchmarkTCPPersistentTimeout(b *testing.B) { func BenchmarkTCP4PersistentTimeout(b *testing.B) {
benchmarkTCP(b, true, true) benchmarkTCP(b, true, true, "127.0.0.1:0")
} }
func benchmarkTCP(b *testing.B, persistent, timeout bool) { func BenchmarkTCP6OneShot(b *testing.B) {
if !supportsIPv6 {
b.Skip("ipv6 is not supported")
}
benchmarkTCP(b, false, false, "[::1]:0")
}
func BenchmarkTCP6OneShotTimeout(b *testing.B) {
if !supportsIPv6 {
b.Skip("ipv6 is not supported")
}
benchmarkTCP(b, false, true, "[::1]:0")
}
func BenchmarkTCP6Persistent(b *testing.B) {
if !supportsIPv6 {
b.Skip("ipv6 is not supported")
}
benchmarkTCP(b, true, false, "[::1]:0")
}
func BenchmarkTCP6PersistentTimeout(b *testing.B) {
if !supportsIPv6 {
b.Skip("ipv6 is not supported")
}
benchmarkTCP(b, true, true, "[::1]:0")
}
func benchmarkTCP(b *testing.B, persistent, timeout bool, laddr string) {
const msgLen = 512 const msgLen = 512
conns := b.N conns := b.N
numConcurrent := runtime.GOMAXPROCS(-1) * 16 numConcurrent := runtime.GOMAXPROCS(-1) * 16
...@@ -61,7 +89,7 @@ func benchmarkTCP(b *testing.B, persistent, timeout bool) { ...@@ -61,7 +89,7 @@ func benchmarkTCP(b *testing.B, persistent, timeout bool) {
} }
return true return true
} }
ln, err := Listen("tcp", "127.0.0.1:0") ln, err := Listen("tcp", laddr)
if err != nil { if err != nil {
b.Fatalf("Listen failed: %v", err) b.Fatalf("Listen failed: %v", err)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment