MCPcopy
hub / github.com/valyala/fasthttp / BenchmarkCopyZeroAllocOSFileToBytesBuffer

Function BenchmarkCopyZeroAllocOSFileToBytesBuffer

http_timing_test.go:12–29  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

10)
11
12func BenchmarkCopyZeroAllocOSFileToBytesBuffer(b *testing.B) {
13 r, err := os.Open("./README.md")
14 if err != nil {
15 b.Fatal(err)
16 }
17 defer r.Close()
18
19 buf := &bytes.Buffer{}
20
21 b.ResetTimer()
22 for i := 0; i < b.N; i++ {
23 buf.Reset()
24 _, err = copyZeroAlloc(buf, r)
25 if err != nil {
26 b.Fatal(err)
27 }
28 }
29}
30
31func BenchmarkCopyZeroAllocBytesBufferToOSFile(b *testing.B) {
32 f, err := os.Open("./README.md")

Callers

nothing calls this directly

Calls 4

copyZeroAllocFunction · 0.85
OpenMethod · 0.80
CloseMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…