mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-11 05:00:25 +08:00
使用新的方法控制缓存并发写入速度
This commit is contained in:
31
internal/utils/fs/status_test.go
Normal file
31
internal/utils/fs/status_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package fsutils_test
|
||||
|
||||
import (
|
||||
fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWrites(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
|
||||
for i := 0; i < fsutils.MaxWrites+1; i++ {
|
||||
fsutils.WriteBegin()
|
||||
}
|
||||
a.IsFalse(fsutils.WriteReady())
|
||||
|
||||
fsutils.WriteEnd()
|
||||
a.IsTrue(fsutils.WriteReady())
|
||||
}
|
||||
|
||||
func BenchmarkWrites(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
fsutils.WriteReady()
|
||||
fsutils.WriteBegin()
|
||||
fsutils.WriteEnd()
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user