qps考虑抓包率

This commit is contained in:
hebo 2019-12-27 18:15:46 +08:00
parent d576e085ff
commit 4114906ece
1 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package communicator
import (
"fmt"
"math"
"sync"
"time"
)
@ -54,6 +55,10 @@ func updateCachedExecTime() {
}
func computeQPS() (qps int64) {
if catpurePacketRate.mysqlCPR <= 0 {
return 0
}
qpsLock.Lock()
defer qpsLock.Unlock()
@ -78,5 +83,8 @@ func computeQPS() (qps int64) {
return 0
}
return time.Second.Nanoseconds() / ((nowNano - minExecTimeNano) / recentRecordNum)
qpsVal := float64(time.Second.Nanoseconds() /
((nowNano - minExecTimeNano) / recentRecordNum)) /
catpurePacketRate.mysqlCPR
return int64(math.Floor(qpsVal))
}