mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-05 00:20:27 +08:00
修复缓存命中率统计测试用例
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeNode/internal/goman"
|
"github.com/TeaOSLab/EdgeNode/internal/goman"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
||||||
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@@ -138,7 +139,7 @@ func (this *Stat) IsGood(category string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.countCached > countSamples && item.timestamp < fasttime.Now().Unix()-600 /** 10 minutes ago **/ {
|
if item.countCached > countSamples && (Tea.IsTesting() || item.timestamp < fasttime.Now().Unix()-600) /** 10 minutes ago **/ {
|
||||||
var isGood = item.countHits*100/item.countCached >= this.goodRatio
|
var isGood = item.countHits*100/item.countCached >= this.goodRatio
|
||||||
if isGood {
|
if isGood {
|
||||||
item.isGood = true
|
item.isGood = true
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ func TestNewStat(t *testing.T) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
var stat = cachehits.NewStat(5)
|
var stat = cachehits.NewStat(5)
|
||||||
for i := 0; i < 10001; i++ {
|
for i := 0; i < 100001; i++ {
|
||||||
stat.IncreaseCached("a")
|
stat.IncreaseCached("a")
|
||||||
}
|
}
|
||||||
for i := 0; i < 499; i++ {
|
for i := 0; i < 4999; i++ {
|
||||||
stat.IncreaseHit("a")
|
stat.IncreaseHit("a")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user