From cbe8ea6c7713664b5e5d93697a25b8699e803ba0 Mon Sep 17 00:00:00 2001 From: Bojan Date: Tue, 10 Jul 2018 21:12:29 -0300 Subject: [PATCH] rename to ghz (#19) * rename to ghz * rename to ghz --- .gitignore | 4 +- README.md | 28 +- cmd/{grpcannon => ghz}/main.go | 18 +- cmd/ghz/out.html | 404 ++++++++++++++++++++++++++ config/config_test.go | 4 +- data.go | 2 +- data_test.go | 4 +- goreleaser.yml | 4 +- printer/printer.go | 8 +- reporter.go | 2 +- requester.go | 4 +- requester_test.go | 6 +- stats_handler.go | 2 +- stats_handler_test.go | 4 +- testdata/{grpcannon.json => ghz.json} | 0 15 files changed, 449 insertions(+), 45 deletions(-) rename cmd/{grpcannon => ghz}/main.go (94%) create mode 100644 cmd/ghz/out.html rename testdata/{grpcannon.json => ghz.json} (100%) diff --git a/.gitignore b/.gitignore index 20a77670..3917764d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,5 @@ # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ -cmd/grpcannon/grpcannon -dist \ No newline at end of file +cmd/ghz/ghz +dist diff --git a/README.md b/README.md index ea222c22..9bc3859a 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,25 @@
-# grpcannon +# ghz -[![build status](https://img.shields.io/travis/bojand/grpcannon/master.svg?style=flat-square)](https://travis-ci.org/bojand/grpcannon) -[![Go Report Card](https://goreportcard.com/badge/github.com/bojand/grpcannon?style=flat-square)](https://goreportcard.com/report/github.com/bojand/grpcannon) +[![build status](https://img.shields.io/travis/bojand/ghz/master.svg?style=flat-square)](https://travis-ci.org/bojand/ghz) +[![Go Report Card](https://goreportcard.com/badge/github.com/bojand/ghz?style=flat-square)](https://goreportcard.com/report/github.com/bojand/ghz) Simple [gRPC](http://grpc.io/) benchmarking and load testing tool inspired by [hey](https://github.com/rakyll/hey/) and [grpcurl](https://github.com/fullstorydev/grpcurl). ## Demo -![demo](grpcannon.gif) +![demo](ghz.gif) ## Install -Download a prebuilt executable binary from the [releases page](https://github.com/bojand/grpcannon/releases). +Download a prebuilt executable binary from the [releases page](https://github.com/bojand/ghz/releases). ## Usage ``` -Usage: grpcannon [options...] +Usage: ghz [options...] Options: -proto The protocol buffer file. -protoset The compiled protoset file. Alternative to proto. -proto takes precedence. @@ -66,26 +66,26 @@ Options: -v Print the version. ``` -Alternatively all settings can be set via `grpcannon.json` file if present in the same path as the `grpcannon` executable. A custom configuration file can be specified using `-config` option. +Alternatively all settings can be set via `ghz.json` file if present in the same path as the `ghz` executable. A custom configuration file can be specified using `-config` option. ## Examples A simple unary call: ```sh -grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Joe"}' 0.0.0.0:50051 +ghz -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Joe"}' 0.0.0.0:50051 ``` Custom number of requests and concurrency: ```sh -grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Joe"}' -n 2000 -c 20 0.0.0.0:50051 +ghz -proto ./greeter.proto -call helloworld.Greeter.SayHello -d '{"name":"Joe"}' -n 2000 -c 20 0.0.0.0:50051 ``` Client streaming data can be sent as an array, each element representing a single message: ```sh -grpcannon -proto ./greeter.proto -call helloworld.Greeter.SayHelloCS -d '[{"name":"Joe"},{"name":"Kate"},{"name":"Sara"}]' 0.0.0.0:50051 +ghz -proto ./greeter.proto -call helloworld.Greeter.SayHelloCS -d '[{"name":"Joe"},{"name":"Kate"},{"name":"Sara"}]' 0.0.0.0:50051 ``` If a single object is given for data it is sent as every message. @@ -98,10 +98,10 @@ Create a protoset protoc --proto_path=. --descriptor_set_out=bundle.protoset *.proto ``` -And then use it as input to `grpcannon` with `-protoset` option: +And then use it as input to `ghz` with `-protoset` option: ``` -./grpcannon -protoset ./bundle.protoset -call helloworld.Greeter.SayHello -d '{"name":"Bob"}' -n 1000 -c 10 0.0.0.0:50051 +./ghz -protoset ./bundle.protoset -call helloworld.Greeter.SayHello -d '{"name":"Bob"}' -n 1000 -c 10 0.0.0.0:50051 ``` Note that only one of `-proto` or `-protoset` options will be used. `-proto` takes precedence. @@ -109,10 +109,10 @@ Note that only one of `-proto` or `-protoset` options will be used. `-proto` tak Using a custom config file: ```sh -grpcannon -config ./config.json +ghz -config ./config.json ``` -Example `grpcannon.json` +Example `ghz.json` ```json { diff --git a/cmd/grpcannon/main.go b/cmd/ghz/main.go similarity index 94% rename from cmd/grpcannon/main.go rename to cmd/ghz/main.go index e68d2c23..4067c2ea 100644 --- a/cmd/grpcannon/main.go +++ b/cmd/ghz/main.go @@ -9,10 +9,10 @@ import ( "strings" "time" - "github.com/bojand/grpcannon" - "github.com/bojand/grpcannon/config" - "github.com/bojand/grpcannon/printer" - "github.com/bojand/grpcannon/protodesc" + "github.com/bojand/ghz" + "github.com/bojand/ghz/config" + "github.com/bojand/ghz/printer" + "github.com/bojand/ghz/protodesc" "github.com/jhump/protoreflect/desc" ) @@ -51,10 +51,10 @@ var ( v = flag.Bool("v", false, "Print the version.") - localConfigName = "grpcannon.json" + localConfigName = "ghz.json" ) -var usage = `Usage: grpcannon [options...] +var usage = `Usage: ghz [options...] Options: -proto The protocol buffer file. -protoset The compiled protoset file. Alternative to proto. -proto takes precedence. @@ -186,13 +186,13 @@ func usageAndExit(msg string) { os.Exit(1) } -func runTest(config *config.Config) (*grpcannon.Report, error) { +func runTest(config *config.Config) (*ghz.Report, error) { mtd, err := getMethodDesc(config) if err != nil { return nil, err } - opts := &grpcannon.Options{ + opts := &ghz.Options{ Host: config.Host, Cert: config.Cert, CName: config.CName, @@ -207,7 +207,7 @@ func runTest(config *config.Config) (*grpcannon.Report, error) { Metadata: config.Metadata, } - reqr, err := grpcannon.New(mtd, opts) + reqr, err := ghz.New(mtd, opts) if err != nil { return nil, err } diff --git a/cmd/ghz/out.html b/cmd/ghz/out.html new file mode 100644 index 00000000..acb8c230 --- /dev/null +++ b/cmd/ghz/out.html @@ -0,0 +1,404 @@ + + + + + + + Results + + + + + + + + + + + +
+ + + +
+
+
+
+ +

Summary

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Count50000
Total1169.51 ms
Slowest12.43 ms
Fastest0.17 ms
Average1.09 ms
Requests / sec42753.01
+
+
+
+
+ +
+
+
+ +

Historam

+
+

+

+

+
+
+ +
+
+
+ +

Latency distribution

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
10 %25 %50 %75 %90 %95 %99 %
0.57 ms0.72 ms0.93 ms1.24 ms1.70 ms2.31 ms5.60 ms
+
+
+ +
+
+
+
+
+ +

Status distribution

+
+ + + + + + + + + + + + + + + + + +
StatusCount% of Total
OK4706994.14 %
+
+
+
+
+ + + +
+
+
+
+
+ +

Errors

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ErrorCount% of Total
rpc error: code = Internal desc = Internal error.15343.07 %
rpc error: code = PermissionDenied desc = Permission denied.9511.90 %
rpc error: code = Unavailable desc = Service unavialable.4460.89 %
+
+
+
+
+ + + +
+
+
+
+
+ +

Data

+
+ + JSON + CSV +
+
+
+
+ +
+
+
+

+ Generated by ghz +

+ +
+
+ +
+ + + + + + + + diff --git a/config/config_test.go b/config/config_test.go index f9e85369..e5362f11 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -246,8 +246,8 @@ func TestConfig_Default(t *testing.T) { func TestConfig_ReadConfig(t *testing.T) { os.Chdir("../testdata/") - t.Run("grpcannon.json", func(t *testing.T) { - c, err := ReadConfig("../testdata/grpcannon.json") + t.Run("ghz.json", func(t *testing.T) { + c, err := ReadConfig("../testdata/ghz.json") assert.NoError(t, err) assert.NotNil(t, c) diff --git a/data.go b/data.go index e8c562bb..cb178dd0 100644 --- a/data.go +++ b/data.go @@ -1,4 +1,4 @@ -package grpcannon +package ghz import ( "encoding/json" diff --git a/data_test.go b/data_test.go index bf904a91..b87bb2f5 100644 --- a/data_test.go +++ b/data_test.go @@ -1,9 +1,9 @@ -package grpcannon +package ghz import ( "testing" - "github.com/bojand/grpcannon/protodesc" + "github.com/bojand/ghz/protodesc" "github.com/stretchr/testify/assert" ) diff --git a/goreleaser.yml b/goreleaser.yml index 21916766..7d686977 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -1,6 +1,6 @@ build: - main: cmd/grpcannon/main.go - binary: grpcannon + main: cmd/ghz/main.go + binary: ghz goos: - darwin - linux diff --git a/printer/printer.go b/printer/printer.go index 1fe37866..c6146d12 100644 --- a/printer/printer.go +++ b/printer/printer.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/alecthomas/template" - "github.com/bojand/grpcannon" + "github.com/bojand/ghz" ) const ( @@ -19,7 +19,7 @@ const ( // ReportPrinter is used for printing the report type ReportPrinter struct { Out io.Writer - Report *grpcannon.Report + Report *ghz.Report } // Print the report using the given format @@ -103,7 +103,7 @@ func formatPercent(num int, total uint64) string { return fmt.Sprintf("%.2f", p*100) } -func histogram(buckets []grpcannon.Bucket) string { +func histogram(buckets []ghz.Bucket) string { max := 0 for _, b := range buckets { if v := b.Count; v > max { @@ -394,7 +394,7 @@ duration (ms),status,error{{ range $i, $v := .Details }}

Generated by ghz

- + diff --git a/reporter.go b/reporter.go index f45fd5a4..7d5eb14c 100644 --- a/reporter.go +++ b/reporter.go @@ -1,4 +1,4 @@ -package grpcannon +package ghz import ( "sort" diff --git a/requester.go b/requester.go index f5ac0739..ea96bfea 100644 --- a/requester.go +++ b/requester.go @@ -1,5 +1,5 @@ -// Package grpcannon provides gRPC benchmarking functionality -package grpcannon +// Package ghz provides gRPC benchmarking functionality +package ghz import ( "context" diff --git a/requester_test.go b/requester_test.go index 84ff9a2d..075d6b7e 100644 --- a/requester_test.go +++ b/requester_test.go @@ -1,4 +1,4 @@ -package grpcannon +package ghz import ( "net" @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/bojand/grpcannon/internal/helloworld" - "github.com/bojand/grpcannon/protodesc" + "github.com/bojand/ghz/internal/helloworld" + "github.com/bojand/ghz/protodesc" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) diff --git a/stats_handler.go b/stats_handler.go index 1ab9e40a..ade41cf8 100644 --- a/stats_handler.go +++ b/stats_handler.go @@ -1,4 +1,4 @@ -package grpcannon +package ghz import ( "context" diff --git a/stats_handler_test.go b/stats_handler_test.go index 19ea5859..e428d7c4 100644 --- a/stats_handler_test.go +++ b/stats_handler_test.go @@ -1,11 +1,11 @@ -package grpcannon +package ghz import ( "context" "testing" "time" - "github.com/bojand/grpcannon/internal/helloworld" + "github.com/bojand/ghz/internal/helloworld" "github.com/stretchr/testify/assert" "google.golang.org/grpc" ) diff --git a/testdata/grpcannon.json b/testdata/ghz.json similarity index 100% rename from testdata/grpcannon.json rename to testdata/ghz.json