Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
cf1b011f
Commit
cf1b011f
authored
Jan 24, 2020
by
Janos Guljas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
measure compete time, not per message in pingpong rtt
parent
e094e221
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
pingpong.go
pkg/pingpong/pingpong.go
+2
-2
No files found.
pkg/pingpong/pingpong.go
View file @
cf1b011f
...
@@ -59,6 +59,7 @@ func (s *Service) Protocol() p2p.ProtocolSpec {
...
@@ -59,6 +59,7 @@ func (s *Service) Protocol() p2p.ProtocolSpec {
}
}
func
(
s
*
Service
)
Ping
(
ctx
context
.
Context
,
address
string
,
msgs
...
string
)
(
rtt
time
.
Duration
,
err
error
)
{
func
(
s
*
Service
)
Ping
(
ctx
context
.
Context
,
address
string
,
msgs
...
string
)
(
rtt
time
.
Duration
,
err
error
)
{
start
:=
time
.
Now
()
stream
,
err
:=
s
.
streamer
.
NewStream
(
ctx
,
address
,
protocolName
,
streamName
,
streamVersion
)
stream
,
err
:=
s
.
streamer
.
NewStream
(
ctx
,
address
,
protocolName
,
streamName
,
streamVersion
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"new stream: %w"
,
err
)
return
0
,
fmt
.
Errorf
(
"new stream: %w"
,
err
)
...
@@ -68,7 +69,6 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
...
@@ -68,7 +69,6 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
var
pong
Pong
var
pong
Pong
start
:=
time
.
Now
()
for
_
,
msg
:=
range
msgs
{
for
_
,
msg
:=
range
msgs
{
if
err
:=
w
.
WriteMsg
(
&
Ping
{
if
err
:=
w
.
WriteMsg
(
&
Ping
{
Greeting
:
msg
,
Greeting
:
msg
,
...
@@ -87,7 +87,7 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
...
@@ -87,7 +87,7 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
s
.
logger
.
Debugf
(
"got pong: %q"
,
pong
.
Response
)
s
.
logger
.
Debugf
(
"got pong: %q"
,
pong
.
Response
)
s
.
metrics
.
PongReceivedCount
.
Inc
()
s
.
metrics
.
PongReceivedCount
.
Inc
()
}
}
return
time
.
Since
(
start
)
/
time
.
Duration
(
len
(
msgs
))
,
nil
return
time
.
Since
(
start
),
nil
}
}
func
(
s
*
Service
)
Handler
(
peer
p2p
.
Peer
,
stream
p2p
.
Stream
)
{
func
(
s
*
Service
)
Handler
(
peer
p2p
.
Peer
,
stream
p2p
.
Stream
)
{
...
...
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