优化计数器

This commit is contained in:
GoEdgeLab
2023-07-15 11:08:25 +08:00
parent f2cd4e2b02
commit 4f8d77d495
4 changed files with 38 additions and 14 deletions

View File

@@ -35,12 +35,14 @@ func TestItem_IsExpired(t *testing.T) {
return
}
var currentTime = time.Now().Unix()
var item = counters.NewItem(10)
t.Log(item.IsExpired())
t.Log(item.IsExpired(currentTime))
time.Sleep(10 * time.Second)
t.Log(item.IsExpired())
t.Log(item.IsExpired(currentTime))
time.Sleep(2 * time.Second)
t.Log(item.IsExpired())
t.Log(item.IsExpired(currentTime))
}
func BenchmarkItem_Increase(b *testing.B) {