goProject/trunk/goutil/fileUtil/bigFile_test.go
皮蛋13361098506 1b77f62820 初始化项目
2025-01-06 16:01:02 +08:00

38 lines
786 B
Go

package fileUtil
import (
"fmt"
"testing"
)
func BenchmarkSaveMessage(b *testing.B) {
path := GetCurrentPath()
fmt.Printf("CurrPath:%s\n", path)
bigFileObj, err := NewBigFile(path, 1024*1024*1024)
if err != nil {
b.Errorf("there should no err, but not there is:%s", err)
}
for i := 0; i < b.N; i++ {
bigFileObj.SaveMessage(fmt.Sprintf("line %d", i))
}
}
func TestSaveMessage(t *testing.T) {
path := GetCurrentPath()
fmt.Printf("CurrPath:%s\n", path)
bigFileObj, err := NewBigFile(path, 1024)
if err != nil {
t.Errorf("there should no err, but not there is:%s", err)
}
for i := 0; i < 100000; i++ {
bigFileObj.SaveMessage(fmt.Sprintf("line %d", i))
}
fileList, err := GetFileList(path)
for _, item := range fileList {
fmt.Printf("file:%s\n", item)
}
}