Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
a2014f10
Commit
a2014f10
authored
Apr 26, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: run benchmarks over HTTP as well as direct network connections.
R=bradfitzgo CC=golang-dev
https://golang.org/cl/4442085
parent
a0a10d19
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
7 deletions
+31
-7
src/pkg/rpc/server_test.go
src/pkg/rpc/server_test.go
+31
-7
No files found.
src/pkg/rpc/server_test.go
View file @
a2014f10
...
...
@@ -344,18 +344,26 @@ func testSendDeadlock(client *Client) {
client
.
Call
(
"Arith.Add"
,
args
,
reply
)
}
func
TestCountMallocs
(
t
*
testing
.
T
)
{
func
dialDirect
()
(
*
Client
,
os
.
Error
)
{
return
Dial
(
"tcp"
,
serverAddr
)
}
func
dialHTTP
()
(
*
Client
,
os
.
Error
)
{
return
DialHTTP
(
"tcp"
,
httpServerAddr
)
}
func
countMallocs
(
dial
func
()
(
*
Client
,
os
.
Error
),
t
*
testing
.
T
)
uint64
{
once
.
Do
(
startServer
)
client
,
err
:=
Dial
(
"tcp"
,
serverAddr
)
client
,
err
:=
dial
(
)
if
err
!=
nil
{
t
.
Error
(
"error dialing"
,
err
)
t
.
Fatal
(
"error dialing"
,
err
)
}
args
:=
&
Args
{
7
,
8
}
reply
:=
new
(
Reply
)
mallocs
:=
0
-
runtime
.
MemStats
.
Mallocs
const
count
=
100
for
i
:=
0
;
i
<
count
;
i
++
{
err
=
client
.
Call
(
"Arith.Add"
,
args
,
reply
)
err
:
=
client
.
Call
(
"Arith.Add"
,
args
,
reply
)
if
err
!=
nil
{
t
.
Errorf
(
"Add: expected no error but got string %q"
,
err
.
String
())
}
...
...
@@ -364,13 +372,21 @@ func TestCountMallocs(t *testing.T) {
}
}
mallocs
+=
runtime
.
MemStats
.
Mallocs
fmt
.
Printf
(
"mallocs per rpc round trip: %d
\n
"
,
mallocs
/
count
)
return
mallocs
/
count
}
func
BenchmarkEndToEnd
(
b
*
testing
.
B
)
{
func
TestCountMallocs
(
t
*
testing
.
T
)
{
fmt
.
Printf
(
"mallocs per rpc round trip: %d
\n
"
,
countMallocs
(
dialDirect
,
t
))
}
func
TestCountMallocsOverHTTP
(
t
*
testing
.
T
)
{
fmt
.
Printf
(
"mallocs per HTTP rpc round trip: %d
\n
"
,
countMallocs
(
dialHTTP
,
t
))
}
func
benchmarkEndToEnd
(
dial
func
()
(
*
Client
,
os
.
Error
),
b
*
testing
.
B
)
{
b
.
StopTimer
()
once
.
Do
(
startServer
)
client
,
err
:=
Dial
(
"tcp"
,
serverAddr
)
client
,
err
:=
dial
(
)
if
err
!=
nil
{
fmt
.
Println
(
"error dialing"
,
err
)
return
...
...
@@ -392,3 +408,11 @@ func BenchmarkEndToEnd(b *testing.B) {
}
}
}
func
BenchmarkEndToEnd
(
b
*
testing
.
B
)
{
benchmarkEndToEnd
(
dialDirect
,
b
)
}
func
BenchmarkEndToEndHTTP
(
b
*
testing
.
B
)
{
benchmarkEndToEnd
(
dialHTTP
,
b
)
}
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