Commit 43f8597b authored by 孙 楠's avatar 孙 楠

Merge branch 'max_qps' into 'master'

Max qps

See merge request !6
parents 6bbefb28 68ccadcd
...@@ -58,6 +58,8 @@ func (p *Path) initQps() { ...@@ -58,6 +58,8 @@ func (p *Path) initQps() {
maxqps, ok := queryOneAndToInt(sql) maxqps, ok := queryOneAndToInt(sql)
if ok { if ok {
p.maxqps = maxqps p.maxqps = maxqps
} else {
p.maxqps = -1
} }
} }
......
...@@ -26,6 +26,9 @@ var ( ...@@ -26,6 +26,9 @@ var (
//Human-readable number //Human-readable number
func hrn(n int) string { func hrn(n int) string {
if n < 0 {
return "未知"
}
num := float64(n) num := float64(n)
unit := float64(1024) unit := float64(1024)
if num < unit { if num < unit {
......
...@@ -47,7 +47,7 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service { ...@@ -47,7 +47,7 @@ func NewService(name string, startTime time.Time, endTime time.Time) *Service {
endTime: endTime, endTime: endTime,
pathMap: make(map[string]*Path), pathMap: make(map[string]*Path),
nodeMap: make(map[string]*Node), nodeMap: make(map[string]*Node),
maxqps: 0, maxqps: -1,
} }
//初始化path //初始化path
...@@ -97,6 +97,8 @@ func (s *Service) initQps() { ...@@ -97,6 +97,8 @@ func (s *Service) initQps() {
maxqps, ok := queryOneAndToInt(sql) maxqps, ok := queryOneAndToInt(sql)
if ok { if ok {
s.maxqps = maxqps s.maxqps = maxqps
} else {
s.maxqps = -1
} }
} }
......
...@@ -194,7 +194,7 @@ func (sm *ServiceMap) GetMaxQps() int { ...@@ -194,7 +194,7 @@ func (sm *ServiceMap) GetMaxQps() int {
} }
//取最大值 //取最大值
max := 0 max := -1
for _, x := range maxList { for _, x := range maxList {
if x > max { if x > max {
max = x max = x
...@@ -211,7 +211,7 @@ func (sm *ServiceMap) getMaxQps(start time.Time, end time.Time) int { ...@@ -211,7 +211,7 @@ func (sm *ServiceMap) getMaxQps(start time.Time, end time.Time) int {
sql := fmt.Sprintf(sqlMaxQps, start.UnixNano(), end.UnixNano()) sql := fmt.Sprintf(sqlMaxQps, start.UnixNano(), end.UnixNano())
maxqps, ok := queryOneAndToInt(sql) maxqps, ok := queryOneAndToInt(sql)
if !ok { if !ok {
return 0 return -1
} }
return maxqps return maxqps
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment