mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
36 lines
820 B
Go
36 lines
820 B
Go
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
|
|
package caches_test
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeNode/internal/caches"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestNewMaxOpenFiles(t *testing.T) {
|
|
var maxOpenFiles = caches.NewMaxOpenFiles()
|
|
maxOpenFiles.Fast()
|
|
t.Log("fast:", maxOpenFiles.Next())
|
|
|
|
maxOpenFiles.Slow()
|
|
t.Log("slow:", maxOpenFiles.Next())
|
|
time.Sleep(1*time.Second + 1*time.Millisecond)
|
|
t.Log("slow 1 second:", maxOpenFiles.Next())
|
|
|
|
maxOpenFiles.Slow()
|
|
t.Log("slow:", maxOpenFiles.Next())
|
|
|
|
maxOpenFiles.Slow()
|
|
t.Log("slow:", maxOpenFiles.Next())
|
|
|
|
time.Sleep(1 * time.Second)
|
|
t.Log("slow 1 second:", maxOpenFiles.Next())
|
|
|
|
maxOpenFiles.Slow()
|
|
t.Log("slow:", maxOpenFiles.Next())
|
|
|
|
maxOpenFiles.Fast()
|
|
t.Log("fast:", maxOpenFiles.Next())
|
|
}
|