diff --git a/tools/benchmark/cmd/root.go b/tools/benchmark/cmd/root.go index e52d97000..d099e6733 100644 --- a/tools/benchmark/cmd/root.go +++ b/tools/benchmark/cmd/root.go @@ -37,6 +37,7 @@ var ( endpoints []string totalConns uint totalClients uint + precise bool sample bool bar *pb.ProgressBar @@ -55,6 +56,7 @@ func init() { RootCmd.PersistentFlags().UintVar(&totalConns, "conns", 1, "Total number of gRPC connections") RootCmd.PersistentFlags().UintVar(&totalClients, "clients", 1, "Total number of gRPC clients") + RootCmd.PersistentFlags().BoolVar(&precise, "precise", false, "use full floating point precision") RootCmd.PersistentFlags().BoolVar(&sample, "sample", false, "'true' to sample requests for every second") RootCmd.PersistentFlags().StringVar(&tls.CertFile, "cert", "", "identify HTTPS client using this SSL certificate file") RootCmd.PersistentFlags().StringVar(&tls.KeyFile, "key", "", "identify HTTPS client using this SSL key file") diff --git a/tools/benchmark/cmd/util.go b/tools/benchmark/cmd/util.go index d11d23f61..456b9bb48 100644 --- a/tools/benchmark/cmd/util.go +++ b/tools/benchmark/cmd/util.go @@ -86,8 +86,12 @@ func mustRandBytes(n int) []byte { } func newReport() report.Report { - if sample { - return report.NewReportSample("%4.4f") + p := "%4.4f" + if precise { + p = "%g" } - return report.NewReport("%4.4f") + if sample { + return report.NewReportSample(p) + } + return report.NewReport(p) }