"log"
"os"
"path/filepath"
+ "runtime"
"strconv"
"sync"
"testing"
func spawnTestSocketPair(t testing.TB, net string) (client, server Conn) {
t.Helper()
+
ln := newLocalListener(t, net)
defer ln.Close()
var cerr, serr error
}
func startTestSocketPeer(t testing.TB, conn Conn, op string, chunkSize, totalSize int) (func(t testing.TB), error) {
+ t.Helper()
+
+ if runtime.GOOS == "windows" {
+ // TODO(panjf2000): Windows has not yet implemented FileConn,
+ // remove this when it's implemented in https://go.dev/issues/9503.
+ t.Fatalf("startTestSocketPeer is not supported on %s", runtime.GOOS)
+ }
+
f, err := conn.(interface{ File() (*os.File, error) }).File()
if err != nil {
return nil, err
}
func BenchmarkSendFile(b *testing.B) {
+ if runtime.GOOS == "windows" {
+ // TODO(panjf2000): Windows has not yet implemented FileConn,
+ // remove this when it's implemented in https://go.dev/issues/9503.
+ b.Skipf("skipping on %s", runtime.GOOS)
+ }
+
b.Run("file-to-tcp", func(b *testing.B) { benchmarkSendFile(b, "tcp") })
b.Run("file-to-unix", func(b *testing.B) { benchmarkSendFile(b, "unix") })
}