Merge "ipc/benchmark: change the directory structure."
diff --git a/runtimes/google/ipc/benchmark/README.txt b/runtimes/google/ipc/benchmark/README.txt
index bc076c6..d44723d 100644
--- a/runtimes/google/ipc/benchmark/README.txt
+++ b/runtimes/google/ipc/benchmark/README.txt
@@ -47,16 +47,16 @@
================================================================================
-bmserver/main.go and bmclient/main.go are simple command-line tools to run the
+benchmarkd/main.go and benchmark/main.go are simple command-line tools to run the
benchmark server and client as separate processes. Unlike the benchmarks above,
this test includes the startup cost of name resolution, creating the VC, etc. in
the first RPC.
-$ v23 go run bmserver/main.go \
+$ v23 go run benchmarkd/main.go \
-veyron.tcp.address=localhost:8888 -veyron.acl.literal='{"Read": {"In": ["..."]}}'
(In a different shell)
-$ v23 go run bmclient/main.go \
+$ v23 go run benchmark/main.go \
-server=/localhost:8888 -iterations=100 -chunk_count=0 -payload_size=10
iterations: 100 chunk_count: 0 payload_size: 10
elapsed time: 1.369034277s
@@ -112,9 +112,9 @@
about 22 ms, and streaming many 1 KB chunks takes about 6.5 ms per chunk.
-$ ./bmserver --address=localhost:8888 --veyron.acl.literal='{"...":"A"}'
+$ ./benchmarkd --address=localhost:8888 --veyron.acl.literal='{"...":"A"}'
-$ ./bmclient --server=/localhost:8888 --count=10 --payload_size=1000
+$ ./benchmark --server=/localhost:8888 --count=10 --payload_size=1000
CallEcho 0 2573406000
CallEcho 1 44669000
CallEcho 2 54442000
diff --git a/runtimes/google/ipc/benchmark/service.vdl b/runtimes/google/ipc/benchmark/benchmark.vdl
similarity index 100%
rename from runtimes/google/ipc/benchmark/service.vdl
rename to runtimes/google/ipc/benchmark/benchmark.vdl
diff --git a/runtimes/google/ipc/benchmark/service.vdl.go b/runtimes/google/ipc/benchmark/benchmark.vdl.go
similarity index 99%
rename from runtimes/google/ipc/benchmark/service.vdl.go
rename to runtimes/google/ipc/benchmark/benchmark.vdl.go
index 8f1c1e9..11c6e5c 100644
--- a/runtimes/google/ipc/benchmark/service.vdl.go
+++ b/runtimes/google/ipc/benchmark/benchmark.vdl.go
@@ -1,5 +1,5 @@
// This file was auto-generated by the veyron vdl tool.
-// Source: service.vdl
+// Source: benchmark.vdl
// package benchmark provides simple tools to measure the performance of the
// IPC system.
diff --git a/runtimes/google/ipc/benchmark/bmclient/main.go b/runtimes/google/ipc/benchmark/benchmark/main.go
similarity index 80%
rename from runtimes/google/ipc/benchmark/bmclient/main.go
rename to runtimes/google/ipc/benchmark/benchmark/main.go
index fdba600..a3cf00f 100644
--- a/runtimes/google/ipc/benchmark/bmclient/main.go
+++ b/runtimes/google/ipc/benchmark/benchmark/main.go
@@ -10,7 +10,7 @@
tbm "v.io/core/veyron/lib/testutil/benchmark"
_ "v.io/core/veyron/profiles"
- "v.io/core/veyron/runtimes/google/ipc/benchmark"
+ "v.io/core/veyron/runtimes/google/ipc/benchmark/internal"
"v.io/v23"
"v.io/v23/vlog"
@@ -33,7 +33,7 @@
if *chunkCntMux > 0 && *payloadSizeMux > 0 {
dummyB := testing.B{}
- _, stop := benchmark.StartEchoStream(&dummyB, ctx, *server, 0, *chunkCntMux, *payloadSizeMux, nil)
+ _, stop := internal.StartEchoStream(&dummyB, ctx, *server, 0, *chunkCntMux, *payloadSizeMux, nil)
defer stop()
vlog.Infof("Started background streaming (chunk_size=%d, payload_size=%d)", *chunkCntMux, *payloadSizeMux)
}
@@ -43,9 +43,9 @@
now := time.Now()
if *chunkCnt == 0 {
- benchmark.CallEcho(&dummyB, ctx, *server, *iterations, *payloadSize, stats)
+ internal.CallEcho(&dummyB, ctx, *server, *iterations, *payloadSize, stats)
} else {
- benchmark.CallEchoStream(&dummyB, ctx, *server, *iterations, *chunkCnt, *payloadSize, stats)
+ internal.CallEchoStream(&dummyB, ctx, *server, *iterations, *chunkCnt, *payloadSize, stats)
}
elapsed := time.Since(now)
diff --git a/runtimes/google/ipc/benchmark/benchmark_test.go b/runtimes/google/ipc/benchmark/benchmark_test.go
index d8d16d3..e5d2f3a 100644
--- a/runtimes/google/ipc/benchmark/benchmark_test.go
+++ b/runtimes/google/ipc/benchmark/benchmark_test.go
@@ -1,15 +1,16 @@
-package benchmark
+package benchmark_test
import (
"os"
"testing"
+ "v.io/v23"
+ "v.io/v23/context"
+
"v.io/core/veyron/lib/testutil"
"v.io/core/veyron/lib/testutil/benchmark"
_ "v.io/core/veyron/profiles/static"
-
- "v.io/v23"
- "v.io/v23/context"
+ "v.io/core/veyron/runtimes/google/ipc/benchmark/internal"
)
var (
@@ -19,7 +20,7 @@
// Benchmarks for non-streaming RPC.
func runEcho(b *testing.B, payloadSize int) {
- CallEcho(b, ctx, serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
+ internal.CallEcho(b, ctx, serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
}
func Benchmark____1B(b *testing.B) { runEcho(b, 1) }
@@ -31,7 +32,7 @@
// Benchmarks for streaming RPC.
func runEchoStream(b *testing.B, chunkCnt, payloadSize int) {
- CallEchoStream(b, ctx, serverAddr, b.N, chunkCnt, payloadSize, benchmark.AddStats(b, 16))
+ internal.CallEchoStream(b, ctx, serverAddr, b.N, chunkCnt, payloadSize, benchmark.AddStats(b, 16))
}
func Benchmark____1_chunk_____1B(b *testing.B) { runEchoStream(b, 1, 1) }
@@ -61,7 +62,7 @@
// Benchmarks for per-chunk throughput in streaming RPC.
func runPerChunk(b *testing.B, payloadSize int) {
- CallEchoStream(b, ctx, serverAddr, 1, b.N, payloadSize, benchmark.NewStats(1))
+ internal.CallEchoStream(b, ctx, serverAddr, 1, b.N, payloadSize, benchmark.NewStats(1))
}
func Benchmark__per_chunk____1B(b *testing.B) { runPerChunk(b, 1) }
@@ -73,8 +74,8 @@
// Benchmarks for non-streaming RPC while running streaming RPC in background.
func runMux(b *testing.B, payloadSize, chunkCntB, payloadSizeB int) {
- _, stop := StartEchoStream(&testing.B{}, ctx, serverAddr, 0, chunkCntB, payloadSizeB, benchmark.NewStats(1))
- CallEcho(b, ctx, serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
+ _, stop := internal.StartEchoStream(&testing.B{}, ctx, serverAddr, 0, chunkCntB, payloadSizeB, benchmark.NewStats(1))
+ internal.CallEcho(b, ctx, serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
stop()
}
@@ -107,10 +108,10 @@
ctx, shutdown = testutil.InitForTest()
var serverStop func()
- serverAddr, serverStop = StartServer(ctx, v23.GetListenSpec(ctx))
+ serverAddr, serverStop = internal.StartServer(ctx, v23.GetListenSpec(ctx))
// Create a VC to exclude the VC setup time from the benchmark.
- CallEcho(&testing.B{}, ctx, serverAddr, 1, 0, benchmark.NewStats(1))
+ internal.CallEcho(&testing.B{}, ctx, serverAddr, 1, 0, benchmark.NewStats(1))
r := benchmark.RunTestMain(m)
diff --git a/runtimes/google/ipc/benchmark/bmserver/main.go b/runtimes/google/ipc/benchmark/benchmarkd/main.go
similarity index 72%
rename from runtimes/google/ipc/benchmark/bmserver/main.go
rename to runtimes/google/ipc/benchmark/benchmarkd/main.go
index 35a374c..8d9b5e7 100644
--- a/runtimes/google/ipc/benchmark/bmserver/main.go
+++ b/runtimes/google/ipc/benchmark/benchmarkd/main.go
@@ -2,19 +2,19 @@
package main
import (
- "v.io/core/veyron/lib/signals"
- _ "v.io/core/veyron/profiles/roaming"
- "v.io/core/veyron/runtimes/google/ipc/benchmark"
-
"v.io/v23"
"v.io/v23/vlog"
+
+ "v.io/core/veyron/lib/signals"
+ _ "v.io/core/veyron/profiles/roaming"
+ "v.io/core/veyron/runtimes/google/ipc/benchmark/internal"
)
func main() {
ctx, shutdown := v23.Init()
defer shutdown()
- addr, stop := benchmark.StartServer(ctx, v23.GetListenSpec(ctx))
+ addr, stop := internal.StartServer(ctx, v23.GetListenSpec(ctx))
vlog.Infof("Listening on %s", addr)
defer stop()
<-signals.ShutdownOnSignals(ctx)
diff --git a/runtimes/google/ipc/benchmark/client.go b/runtimes/google/ipc/benchmark/internal/client.go
similarity index 89%
rename from runtimes/google/ipc/benchmark/client.go
rename to runtimes/google/ipc/benchmark/internal/client.go
index 2acb683..ac809dc 100644
--- a/runtimes/google/ipc/benchmark/client.go
+++ b/runtimes/google/ipc/benchmark/internal/client.go
@@ -1,4 +1,4 @@
-package benchmark
+package internal
import (
"bytes"
@@ -6,15 +6,16 @@
"testing"
"time"
- "v.io/core/veyron/lib/testutil/benchmark"
-
"v.io/v23/context"
"v.io/v23/vlog"
+
+ tbm "v.io/core/veyron/lib/testutil/benchmark"
+ "v.io/core/veyron/runtimes/google/ipc/benchmark"
)
// CallEcho calls 'Echo' method 'iterations' times with the given payload size.
-func CallEcho(b *testing.B, ctx *context.T, address string, iterations, payloadSize int, stats *benchmark.Stats) {
- stub := BenchmarkClient(address)
+func CallEcho(b *testing.B, ctx *context.T, address string, iterations, payloadSize int, stats *tbm.Stats) {
+ stub := benchmark.BenchmarkClient(address)
payload := make([]byte, payloadSize)
for i := range payload {
payload[i] = byte(i & 0xff)
@@ -46,7 +47,7 @@
// CallEchoStream calls 'EchoStream' method 'iterations' times. Each iteration sends
// 'chunkCnt' chunks on the stream and receives the same number of chunks back. Each
// chunk has the given payload size.
-func CallEchoStream(b *testing.B, ctx *context.T, address string, iterations, chunkCnt, payloadSize int, stats *benchmark.Stats) {
+func CallEchoStream(b *testing.B, ctx *context.T, address string, iterations, chunkCnt, payloadSize int, stats *tbm.Stats) {
done, _ := StartEchoStream(b, ctx, address, iterations, chunkCnt, payloadSize, stats)
<-done
}
@@ -56,8 +57,8 @@
// it's done. It also returns a callback function to stop the streaming. Each iteration
// requests 'chunkCnt' chunks on the stream and receives that number of chunks back.
// Each chunk has the given payload size. Zero 'iterations' means unlimited.
-func StartEchoStream(b *testing.B, ctx *context.T, address string, iterations, chunkCnt, payloadSize int, stats *benchmark.Stats) (<-chan int, func()) {
- stub := BenchmarkClient(address)
+func StartEchoStream(b *testing.B, ctx *context.T, address string, iterations, chunkCnt, payloadSize int, stats *tbm.Stats) (<-chan int, func()) {
+ stub := benchmark.BenchmarkClient(address)
payload := make([]byte, payloadSize)
for i := range payload {
payload[i] = byte(i & 0xff)
diff --git a/runtimes/google/ipc/benchmark/server.go b/runtimes/google/ipc/benchmark/internal/server.go
similarity index 81%
rename from runtimes/google/ipc/benchmark/server.go
rename to runtimes/google/ipc/benchmark/internal/server.go
index 6c5696a..c8b6a84 100644
--- a/runtimes/google/ipc/benchmark/server.go
+++ b/runtimes/google/ipc/benchmark/internal/server.go
@@ -1,4 +1,4 @@
-package benchmark
+package internal
import (
"v.io/core/veyron/security/flag"
@@ -7,6 +7,8 @@
"v.io/v23/context"
"v.io/v23/ipc"
"v.io/v23/vlog"
+
+ "v.io/core/veyron/runtimes/google/ipc/benchmark"
)
type impl struct {
@@ -16,7 +18,7 @@
return payload, nil
}
-func (i *impl) EchoStream(ctx BenchmarkEchoStreamContext) error {
+func (i *impl) EchoStream(ctx benchmark.BenchmarkEchoStreamContext) error {
rStream := ctx.RecvStream()
sStream := ctx.SendStream()
for rStream.Advance() {
@@ -41,7 +43,7 @@
vlog.Fatalf("Listen failed: %v", err)
}
- if err := server.Serve("", BenchmarkServer(&impl{}), flag.NewAuthorizerOrDie()); err != nil {
+ if err := server.Serve("", benchmark.BenchmarkServer(&impl{}), flag.NewAuthorizerOrDie()); err != nil {
vlog.Fatalf("Serve failed: %v", err)
}
return eps[0].Name(), func() {