Commit e5ae32e9 authored by jingbo.wang's avatar jingbo.wang

qps ok

parent 14e41c9b
......@@ -7,7 +7,7 @@ import (
)
func TestRun(t *testing.T) {
sm := NewServiceMap(time.Now().AddDate(0, 0, -10), time.Now())
sm := NewServiceMap(time.Now().AddDate(0, 0, -10), time.Now(), []string{"cuishou"})
smForm := sm.ReportForm("day")
fmt.Println(smForm)
......
......@@ -173,7 +173,7 @@ func (sm *ServiceMap) GetQps() float64 {
//获取最大qps
func (sm *ServiceMap) GetMaxQps() int {
//单位秒
const lang = 3600
const lang = 3600 * 12
t := sm.endTime.Unix() - sm.startTime.Unix()
if t <= 0 {
return 0
......@@ -184,13 +184,13 @@ func (sm *ServiceMap) GetMaxQps() int {
end := sm.endTime
maxList := make([]int, 0)
for start.Unix() < end.Unix() {
glog.Info("分段统计MaxQps: ", start.Format(timeFormat), end.Format(timeFormat))
if start.Unix()+lang < end.Unix() {
maxList = append(maxList, sm.getMaxQps(start, end))
start = start.Add(time.Second * lang)
} else {
maxList = append(maxList, sm.getMaxQps(start, sm.endTime))
break
}
start = start.Add(time.Second * lang)
}
//取最大值
......
......@@ -6,8 +6,9 @@ import (
)
func TestNewServiceMap(t *testing.T) {
sm := NewServiceMap(time.Now().Add(time.Hour*24*-7), time.Now())
sm := NewServiceMap(time.Now().Add(time.Hour*24*-7), time.Now(), []string{"cuishou"})
t.Log("qps", sm.GetMaxQps())
t.Log("访问量:", sm.GetCount())
t.Log("总访问时间:", sm.GetSumDuration())
t.Log("总平均访问时间:", sm.GetAverageDuration())
......
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