mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-09-19 18:19:20 +08:00
qps考虑抓包率
This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user