Skip to content

Commit 5520fe6

Browse files
committed
chore(bench): update
Change-Id: I39f3d7468fb121ed894787df0fc87604e0e82784
1 parent 9cc756c commit 5520fe6

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

examples/bench/client.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import (
1616

1717
//go:generate go build $GOFILE
1818

19-
var concurrency = flag.Int("c", 1, "concurrency")
20-
var total = flag.Int("n", 1, "total requests for all clients")
21-
var host = flag.String("s", "127.0.0.1:8972", "server ip and port")
22-
var debugAddr = flag.String("d", "127.0.0.1:9982", "server ip and port")
19+
var (
20+
concurrency = flag.Int("c", 1, "concurrency")
21+
total = flag.Int("n", 1, "total requests for all clients")
22+
host = flag.String("s", "127.0.0.1:8972", "server ip and port")
23+
debugAddr = flag.String("d", "127.0.0.1:9982", "server ip and port")
24+
network = flag.String("network", "tcp", "network")
25+
)
2326

2427
func main() {
2528
flag.Parse()
@@ -43,6 +46,7 @@ func main() {
4346

4447
serviceMethod := "Hello.Say"
4548
client := erpc.NewPeer(erpc.PeerConfig{
49+
Network: *network,
4650
DefaultBodyCodec: "protobuf",
4751
})
4852

examples/bench/mclient.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ import (
1616

1717
//go:generate go build $GOFILE
1818

19-
var concurrency = flag.Int("c", 1, "concurrency")
20-
var total = flag.Int("n", 1, "total requests for all clients")
21-
var host = flag.String("s", "127.0.0.1:8972", "server ip and port")
19+
var (
20+
concurrency = flag.Int("c", 1, "concurrency")
21+
total = flag.Int("n", 1, "total requests for all clients")
22+
host = flag.String("s", "127.0.0.1:8972", "server ip and port")
23+
network = flag.String("network", "tcp", "network")
24+
)
2225

2326
func main() {
2427
flag.Parse()
@@ -38,6 +41,7 @@ func main() {
3841

3942
serviceMethod := "Hello.Say"
4043
client := erpc.NewPeer(erpc.PeerConfig{
44+
Network: *network,
4145
DefaultBodyCodec: "protobuf",
4246
})
4347

examples/bench/server.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,11 @@ import (
1414

1515
//go:generate go build $GOFILE
1616

17-
type Hello struct {
18-
erpc.CallCtx
19-
}
20-
21-
func (t *Hello) Say(args *msg.BenchmarkMessage) (*msg.BenchmarkMessage, *erpc.Status) {
22-
s := "OK"
23-
var i int32 = 100
24-
args.Field1 = s
25-
args.Field2 = i
26-
if *delay > 0 {
27-
time.Sleep(*delay)
28-
} else {
29-
runtime.Gosched()
30-
}
31-
return args, nil
32-
}
33-
3417
var (
3518
port = flag.Int64("p", 8972, "listened port")
3619
delay = flag.Duration("delay", 0, "delay to mock business processing")
3720
debugAddr = flag.String("d", "127.0.0.1:9981", "server ip and port")
21+
network = flag.String("network", "tcp", "network")
3822
)
3923

4024
func main() {
@@ -49,9 +33,27 @@ func main() {
4933

5034
erpc.SetServiceMethodMapper(erpc.RPCServiceMethodMapper)
5135
server := erpc.NewPeer(erpc.PeerConfig{
36+
Network: *network,
5237
DefaultBodyCodec: "protobuf",
5338
ListenPort: uint16(*port),
5439
})
5540
server.RouteCall(new(Hello))
5641
server.ListenAndServe()
5742
}
43+
44+
type Hello struct {
45+
erpc.CallCtx
46+
}
47+
48+
func (t *Hello) Say(args *msg.BenchmarkMessage) (*msg.BenchmarkMessage, *erpc.Status) {
49+
s := "OK"
50+
var i int32 = 100
51+
args.Field1 = s
52+
args.Field2 = i
53+
if *delay > 0 {
54+
time.Sleep(*delay)
55+
} else {
56+
runtime.Gosched()
57+
}
58+
return args, nil
59+
}

0 commit comments

Comments
 (0)