优化计数器

This commit is contained in:
刘祥超
2023-07-15 11:08:25 +08:00
parent 2079b0ebee
commit 1fdce3ef7e
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) {