(b *testing.B)
| 32 | ) |
| 33 | |
| 34 | func BenchmarkConnectionIO(b *testing.B) { |
| 35 | dataSize := 1024 * 16 |
| 36 | writeBuffer := make([]byte, dataSize) |
| 37 | rfd, wfd := GetSysFdPairs() |
| 38 | rconn, wconn := new(connection), new(connection) |
| 39 | rconn.init(&netFD{fd: rfd}, &options{onRequest: func(ctx context.Context, connection Connection) error { |
| 40 | read, _ := connection.Reader().Next(dataSize) |
| 41 | _ = wconn.Reader().Release() |
| 42 | _, _ = connection.Writer().WriteBinary(read) |
| 43 | _ = connection.Writer().Flush() |
| 44 | return nil |
| 45 | }}) |
| 46 | wconn.init(&netFD{fd: wfd}, new(options)) |
| 47 | |
| 48 | b.ResetTimer() |
| 49 | b.ReportAllocs() |
| 50 | for i := 0; i < b.N; i++ { |
| 51 | _, _ = wconn.WriteBinary(writeBuffer) |
| 52 | _ = wconn.Flush() |
| 53 | _, _ = wconn.Reader().Next(dataSize) |
| 54 | _ = wconn.Reader().Release() |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func TestConnectionWrite(t *testing.T) { |
| 59 | cycle, caps := 10000, 256 |
nothing calls this directly
no test coverage detected
searching dependent graphs…