mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-18 03:35:10 +08:00
bfs:实现maxOpenFiles
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user