MCPcopy
hub / github.com/NVIDIA/aistore / benchFile

Function benchFile

memsys/d256_test.go:223–263  ·  view source on GitHub ↗
(b *testing.B, sbufSize int64)

Source from the content-addressed store, hash-verified

221}
222
223func benchFile(b *testing.B, sbufSize int64) {
224 mem := &memsys.MMSA{Name: "gmem", MinPctFree: 50}
225 mem.Init(0)
226 defer mem.Terminate(false)
227
228 // reset initial conditions
229 cos.FreeMemToOS()
230
231 file, err := os.CreateTemp("/tmp", "")
232 if err != nil {
233 b.Fatal(err)
234 }
235 n, _ := file.Write(make([]byte, largefil))
236 if int64(n) != largefil {
237 b.Fatal(n, largefil)
238 }
239
240 defer func() {
241 file.Close()
242 os.Remove(file.Name())
243 }()
244
245 slab, err := mem.GetSlab(sbufSize)
246 cos.AssertNoErr(err)
247 buf := slab.Alloc()
248 defer slab.Free(buf)
249
250 if int64(len(buf)) != sbufSize {
251 b.Fatal(len(buf), sbufSize)
252 }
253
254 b.ResetTimer() // start timing it
255 for i := 0; i < b.N; i++ {
256 file.Seek(0, io.SeekStart)
257 n, _ := io.CopyBuffer(io.Discard, file, buf)
258 if n != largefil {
259 b.Fatal(n, largefil)
260 }
261 }
262 b.StopTimer() // wo/ defers
263}

Callers 4

BenchmarkLargeFileMaxFunction · 0.85
BenchmarkLargeFile128KFunction · 0.85
BenchmarkLargeFile64KFunction · 0.85
BenchmarkLargeFile32KFunction · 0.85

Calls 12

InitMethod · 0.95
TerminateMethod · 0.95
GetSlabMethod · 0.95
FreeMemToOSFunction · 0.92
AssertNoErrFunction · 0.92
CloseMethod · 0.65
NameMethod · 0.65
WriteMethod · 0.45
RemoveMethod · 0.45
AllocMethod · 0.45
FreeMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected