| 1 | package test |
| 2 | |
| 3 | import ( |
| 4 | "io" |
| 5 | "net" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestStressIOPipe(t *testing.T) { |
| 10 | r, w := io.Pipe() |
| 11 | |
| 12 | opt := Options{ |
| 13 | MsgSize: 2048, |
| 14 | MsgCount: 100, |
| 15 | } |
| 16 | |
| 17 | err := Stress(w, r, opt) |
| 18 | if err != nil { |
| 19 | t.Fatal(err) |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func TestStressDuplexNetPipe(t *testing.T) { |
| 24 | ca, cb := net.Pipe() |
| 25 | |
| 26 | opt := Options{ |
| 27 | MsgSize: 2048, |
| 28 | MsgCount: 100, |
| 29 | } |
| 30 | |
| 31 | err := StressDuplex(ca, cb, opt) |
| 32 | if err != nil { |
| 33 | t.Fatal(err) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func BenchmarkPipe(b *testing.B) { |
| 38 | ca, cb := net.Pipe() |
| 39 | |
| 40 | b.ResetTimer() |
| 41 | |
| 42 | opt := Options{ |
| 43 | MsgSize: 2048, |
| 44 | MsgCount: b.N, |
| 45 | } |
| 46 | |
| 47 | check(Stress(ca, cb, opt)) |
| 48 | } |
| 49 | |
| 50 | func check(err error) { |
| 51 | if err != nil { |
| 52 | panic(err) |
| 53 | } |
| 54 | } |