Skip to content

Commit b59f7ea

Browse files
resolve comments
Signed-off-by: Said Altury <Said.Altury@ibm.com>
1 parent 29aeb1e commit b59f7ea

File tree

3 files changed

+59
-41
lines changed

3 files changed

+59
-41
lines changed

integration/benchmark/grpc/grpc_bench_test.go

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package test
88

99
import (
1010
"encoding/json"
11-
"flag"
1211
"testing"
1312
"time"
1413

@@ -24,10 +23,8 @@ import (
2423
"go.opentelemetry.io/otel/trace/noop"
2524
)
2625

27-
var workload = flag.String("workload", "ecdsa", "workload type: cpu or ecdsa") // ecdsa is the Default workload
28-
29-
func BenchmarkGRPC(b *testing.B) {
30-
srvEndpoint := setupServer(b)
26+
func BenchmarkGRPCSingleConnectionCPU(b *testing.B) {
27+
srvEndpoint := setupServer(b, "cpu")
3128

3229
// we share a single connection among all client goroutines
3330
cli, closeF := setupClient(b, srvEndpoint)
@@ -43,7 +40,60 @@ func BenchmarkGRPC(b *testing.B) {
4340
benchmark.ReportTPS(b)
4441
}
4542

46-
func setupServer(tb testing.TB) string {
43+
func BenchmarkGRPCMultiConnectionCPU(b *testing.B) {
44+
srvEndpoint := setupServer(b, "cpu")
45+
46+
b.RunParallel(func(pb *testing.PB) {
47+
// each goroutine gets its own client + connection
48+
cli, closeF := setupClient(b, srvEndpoint)
49+
defer closeF()
50+
51+
for pb.Next() {
52+
resp, err := cli.CallViewWithContext(b.Context(), "fid", nil)
53+
require.NoError(b, err)
54+
require.NotNil(b, resp)
55+
}
56+
})
57+
58+
benchmark.ReportTPS(b)
59+
}
60+
61+
// --- ECDSA Workload Benchmarks ---
62+
63+
func BenchmarkGRPCSingleConnectionECDSA(b *testing.B) {
64+
srvEndpoint := setupServer(b, "ecdsa")
65+
cli, closeF := setupClient(b, srvEndpoint)
66+
defer closeF()
67+
68+
b.ResetTimer()
69+
b.RunParallel(func(pb *testing.PB) {
70+
for pb.Next() {
71+
resp, err := cli.CallViewWithContext(b.Context(), "fid", nil)
72+
require.NoError(b, err)
73+
require.NotNil(b, resp)
74+
}
75+
})
76+
benchmark.ReportTPS(b)
77+
}
78+
79+
func BenchmarkGRPCMultiConnectionECDSA(b *testing.B) {
80+
srvEndpoint := setupServer(b, "ecdsa")
81+
82+
b.ResetTimer()
83+
b.RunParallel(func(pb *testing.PB) {
84+
cli, closeF := setupClient(b, srvEndpoint)
85+
defer closeF()
86+
87+
for pb.Next() {
88+
resp, err := cli.CallViewWithContext(b.Context(), "fid", nil)
89+
require.NoError(b, err)
90+
require.NotNil(b, resp)
91+
}
92+
})
93+
benchmark.ReportTPS(b)
94+
}
95+
96+
func setupServer(tb testing.TB, workloadType string) string {
4797
tb.Helper()
4898

4999
mDefaultIdentity := view.Identity("server identity")
@@ -84,7 +134,7 @@ func setupServer(tb testing.TB) string {
84134
require.NotNil(tb, srv)
85135

86136
var v view.View
87-
switch *workload {
137+
switch workloadType {
88138
case "cpu":
89139
parms := &benchviews.CPUParams{N: 200000}
90140
input, _ := json.Marshal(parms)
@@ -96,7 +146,7 @@ func setupServer(tb testing.TB) string {
96146
factory := &benchviews.ECDSASignViewFactory{}
97147
v, _ = factory.NewView(input)
98148
default:
99-
tb.Fatalf("unknown workload type: %s", *workload)
149+
tb.Fatalf("unknown workload type: %s", workloadType)
100150
}
101151

102152
// our view manager

integration/benchmark/grpc/grpc_multi_connection_bench_test.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

integration/benchmark/grpc/view_bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func BenchmarkView(b *testing.B) {
17-
srvEndpoint := setupServer(b)
17+
srvEndpoint := setupServer(b, "cpu")
1818

1919
// we share a single connection among all client goroutines
2020
cli, closeF := setupClient(b, srvEndpoint)

0 commit comments

Comments
 (0)