mirror of
https://github.com/zr-hebo/sniffer-agent.git
synced 2025-08-11 20:34:46 +08:00
use cache reduce malloc
This commit is contained in:
@@ -82,6 +82,10 @@ func outletSetConfig(resp http.ResponseWriter, req *http.Request) {
|
||||
mp.Err = SetConfig(ep.ConfigName, ep.Value)
|
||||
}
|
||||
|
||||
func GetThrowPacketRate() float64 {
|
||||
return throwPacketRate.value
|
||||
func GetTCPThrowPacketRate() float64 {
|
||||
return throwPacketRate.tcpTPR
|
||||
}
|
||||
|
||||
func GetMysqlThrowPacketRate() float64 {
|
||||
return throwPacketRate.mysqlTPR
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
package communicator
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
type configItem interface {
|
||||
setVal (interface{}) error
|
||||
@@ -9,13 +12,15 @@ type configItem interface {
|
||||
|
||||
type throwPacketRateConfig struct {
|
||||
name string
|
||||
value float64
|
||||
tcpTPR float64
|
||||
mysqlTPR float64
|
||||
}
|
||||
|
||||
func newThrowPacketRateConfig() (tpr *throwPacketRateConfig) {
|
||||
tpr = &throwPacketRateConfig{
|
||||
name: THROW_PACKET_RATE,
|
||||
value: 0.0,
|
||||
tcpTPR: 0.0,
|
||||
mysqlTPR: 0.0,
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -27,14 +32,11 @@ func (tc *throwPacketRateConfig) setVal (val interface{}) (err error){
|
||||
return
|
||||
}
|
||||
|
||||
tc.value = realVal
|
||||
tc.mysqlTPR = realVal
|
||||
tc.tcpTPR = math.Sqrt(realVal)
|
||||
return
|
||||
}
|
||||
|
||||
func (tc *throwPacketRateConfig) getVal () (val interface{}){
|
||||
return tc.value
|
||||
}
|
||||
|
||||
func (tc *throwPacketRateConfig) GetValFloat64 () (val float64){
|
||||
return tc.value
|
||||
}
|
||||
return tc.mysqlTPR
|
||||
}
|
Reference in New Issue
Block a user