bfs:实现maxOpenFiles

This commit is contained in:
刘祥超
2024-04-27 17:29:12 +08:00
parent 04007bf8f1
commit 801f5d4525
9 changed files with 318 additions and 54 deletions

View File

@@ -5,9 +5,11 @@ package bfs_test
import (
"github.com/TeaOSLab/EdgeNode/internal/utils/bfs"
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
"github.com/TeaOSLab/EdgeNode/internal/utils/testutils"
"github.com/iwind/TeaGo/logs"
"sync"
"testing"
"time"
)
func TestNewMetaFile(t *testing.T) {
@@ -24,6 +26,28 @@ func TestNewMetaFile(t *testing.T) {
//logs.PrintAsJSON(mFile.Headers(), t)
}
func TestNewMetaFile_Large(t *testing.T) {
var count = 2
if testutils.IsSingleTesting() {
count = 100
}
var before = time.Now()
for i := 0; i < count; i++ {
mFile, err := bfs.OpenMetaFile("testdata/test2.m", &sync.RWMutex{})
if err != nil {
if bfs.IsNotExist(err) {
continue
}
t.Fatal(err)
}
_ = mFile.Close()
}
var costMs = time.Since(before).Seconds() * 1000
t.Logf("cost: %.2fms, qps: %.2fms/file", costMs, costMs/float64(count))
}
func TestMetaFile_WriteMeta(t *testing.T) {
mFile, err := bfs.OpenMetaFile("testdata/test.m", &sync.RWMutex{})
if err != nil {