qps考虑抓包率
This commit is contained in:
parent
d576e085ff
commit
4114906ece
|
@ -2,6 +2,7 @@ package communicator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -54,6 +55,10 @@ func updateCachedExecTime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func computeQPS() (qps int64) {
|
func computeQPS() (qps int64) {
|
||||||
|
if catpurePacketRate.mysqlCPR <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
qpsLock.Lock()
|
qpsLock.Lock()
|
||||||
defer qpsLock.Unlock()
|
defer qpsLock.Unlock()
|
||||||
|
|
||||||
|
@ -78,5 +83,8 @@ func computeQPS() (qps int64) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return time.Second.Nanoseconds() / ((nowNano - minExecTimeNano) / recentRecordNum)
|
qpsVal := float64(time.Second.Nanoseconds() /
|
||||||
|
((nowNano - minExecTimeNano) / recentRecordNum)) /
|
||||||
|
catpurePacketRate.mysqlCPR
|
||||||
|
return int64(math.Floor(qpsVal))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue