This directory contains benchmark code used to measure overhead of generated client libraries.
This directory is experimental. It might be changed or removed in the future.
Our benchmarks use TLS connections.
If the benchmark and the mock server is run on the same machine,
you can create your own TLS certificate by following directions
here
and configure Common Name
to localhost
.
The server
directory contains a mock server that benchmarks can call RPCs against.
To run the server:
- Install Go
- Install dependencies
go get -u google.golang.org/genproto/googleapis/pubsub/v1 google.golang.org/grpc
go run server.go -key <keyfile> -cert <certfile>
- where
keyfile
andcertfile
are TLS key and certificate files, respectively - by default, server will start on
localhost:8080
- for more configuration, run
go run server.go -help
- where
Benchmarks of most languages accept some of the same options.
cert_file
- This is the TLS certificate file that the benchmark will use to established secured connection with the server.
client
- This option should either be "grpc" or "gapic", depending on which client you wish to benchmark.
num_workers
- This option controls how many concurrent RPCs may be made to the server.
- Set to 1, the benchmark will measure RPC latency.
- Set to a large number (say 20) the benchmark will fully load a CPU and measure CPU cost.
By default, benchmarks will make RPCs against the server at localhost:8080
.
Benchmark for Java is located in the clients/java/pubsub
directory.
To run the benchmark, you need to install Maven.
To run:
mvn exec:java -Dexec.mainClass="com.google.cloud.bench.Pubsub" -Dexec.args="-cert <cert_file> -c <client> -n <num_workers>"
For more configuration, run the command with -Dexec.args="-help"
to bring up the help menu.
Benchmark for Go is located at clients/go/local.go
.
To run:
go run clients/go/local.go -cert <cert_file> -client <client> -num_workers <num_workers>
For the help menu, run go run clients/go/local.go -help
.
Benchmark for PHP is located at clients/php/local.php
.
To install dependencies:
composer install
To run:
php local.php -cert <cert_file> -client <client>
PHP does not support async calls.