MCPcopy
hub / github.com/Terry-Mao/goim / BenchmarkReaderCopyOptimal

Function BenchmarkReaderCopyOptimal

pkg/bufio/bufio_test.go:889–901  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

887}
888
889func BenchmarkReaderCopyOptimal(b *testing.B) {
890 // Optimal case is where the underlying reader implements io.WriterTo
891 srcBuf := bytes.NewBuffer(make([]byte, 8192))
892 src := NewReader(srcBuf)
893 dstBuf := new(bytes.Buffer)
894 dst := onlyWriter{dstBuf}
895 for i := 0; i < b.N; i++ {
896 srcBuf.Reset()
897 src.Reset(srcBuf)
898 dstBuf.Reset()
899 _, _ = io.Copy(dst, src)
900 }
901}
902
903func BenchmarkReaderCopyUnoptimal(b *testing.B) {
904 // Unoptimal case is where the underlying reader doesn't implement io.WriterTo

Callers

nothing calls this directly

Calls 2

ResetMethod · 0.95
NewReaderFunction · 0.85

Tested by

no test coverage detected