| // Number of bytes to read/write |
| throughputBlockSize = 50 << 10 // 50 KB |
| type throughputTester struct { |
| func (t *throughputTester) Run() { |
| t.pending.Add(len(t.writers) + len(t.readers)) |
| iters := t.b.N / len(t.writers) |
| t.data = make([]byte, throughputBlockSize) |
| if n, err := rand.Read(t.data); n != len(t.data) || err != nil { |
| t.b.Fatalf("Failed to fill write buffer with data: (%d, %v)", n, err) |
| for _, w := range t.writers { |
| for _, r := range t.readers { |
| func (t *throughputTester) writeLoop(w io.WriteCloser, N int) { |
| t.b.SetBytes(int64(size)) |
| if n, err := w.Write(t.data); err != nil || n != size { |
| t.b.Fatalf("Write error: %v", err) |
| func (t *throughputTester) readLoop(r io.ReadCloser) { |
| var buf [throughputBlockSize]byte |
| t.b.Errorf("Read returned (%d, %v)", n, err) |