MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestFileReader_Read_LargeFile

Function TestFileReader_Read_LargeFile

internal/utils/bfs/file_reader_test.go:86–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestFileReader_Read_LargeFile(t *testing.T) {
87 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)
88 if err != nil {
89 if os.IsNotExist(err) {
90 t.Log(err)
91 return
92 }
93 t.Fatal(err)
94 }
95
96 reader, err := bFile.OpenFileReader(bfs.Hash("123456@LARGE"), false)
97 if err != nil {
98 if os.IsNotExist(err) {
99 t.Log(err)
100 return
101 }
102 t.Fatal(err)
103 }
104
105 defer func() {
106 _ = reader.Close()
107 }()
108
109 var buf = make([]byte, 16<<10)
110 var totalSize int64
111 var before = time.Now()
112 for {
113 n, readErr := reader.Read(buf)
114 if n > 0 {
115 totalSize += int64(n)
116 }
117 if readErr != nil {
118 if readErr == io.EOF {
119 break
120 }
121 t.Fatal(readErr)
122 }
123 }
124 t.Log("totalSize:", totalSize>>20, "MiB", "cost:", fmt.Sprintf("%.4fms", time.Since(before).Seconds()*1000))
125}
126
127func TestFileReader_ReadAt(t *testing.T) {
128 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)

Callers

nothing calls this directly

Calls 6

OpenBlocksFileFunction · 0.92
HashFunction · 0.92
LogMethod · 0.80
CloseMethod · 0.65
ReadMethod · 0.65
OpenFileReaderMethod · 0.45

Tested by

no test coverage detected