Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
e5ae32e9
Commit
e5ae32e9
authored
Dec 24, 2019
by
jingbo.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qps ok
parent
14e41c9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
5 deletions
+6
-5
report_form_test.go
pkg/report-form/report_form_test.go
+1
-1
service_map.go
pkg/report-form/service_map.go
+3
-3
service_map_test.go
pkg/report-form/service_map_test.go
+2
-1
No files found.
pkg/report-form/report_form_test.go
View file @
e5ae32e9
...
...
@@ -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
)
...
...
pkg/report-form/service_map.go
View file @
e5ae32e9
...
...
@@ -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
)
}
//取最大值
...
...
pkg/report-form/service_map_test.go
View file @
e5ae32e9
...
...
@@ -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
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment