Skip to content

Commit

Permalink
Properly printer output of Rps. Fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Apr 8, 2018
1 parent adca8ad commit aa6de5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Summary:
Slowest: 15.41 ms
Fastest: 0.66 ms
Average: 6.83 ms
Requests/sec: 5788347.22
Requests/sec: 5788.35
Response time histogram:
0.664 [1] |
Expand Down
Binary file modified grpcannon.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 16 additions & 11 deletions printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,25 @@ func (rp *ReportPrinter) printf(s string, v ...interface{}) {
}

var tmplFuncMap = template.FuncMap{
"formatNumber": formatNumber,
"histogram": histogram,
"jsonify": jsonify,
"formatMilli": formatMilli,
"formatSeconds": formatSeconds,
"histogram": histogram,
"jsonify": jsonify,
}

func jsonify(v interface{}) string {
d, _ := json.Marshal(v)
return string(d)
}

func formatNumber(duration float64) string {
func formatMilli(duration float64) string {
return fmt.Sprintf("%4.2f", duration*1000)
}

func formatSeconds(duration float64) string {
return fmt.Sprintf("%4.2f", duration)
}

func histogram(buckets []grpcannon.Bucket) string {
max := 0
for _, b := range buckets {
Expand All @@ -87,16 +92,16 @@ var (
defaultTmpl = `
Summary:
Count: {{ .Count }}
Total: {{ formatNumber .Total.Seconds }} ms
Slowest: {{ formatNumber .Slowest.Seconds }} ms
Fastest: {{ formatNumber .Fastest.Seconds }} ms
Average: {{ formatNumber .Average.Seconds }} ms
Requests/sec: {{ formatNumber .Rps }}
Total: {{ formatMilli .Total.Seconds }} ms
Slowest: {{ formatMilli .Slowest.Seconds }} ms
Fastest: {{ formatMilli .Fastest.Seconds }} ms
Average: {{ formatMilli .Average.Seconds }} ms
Requests/sec: {{ formatSeconds .Rps }}
Response time histogram:
{{ histogram .Histogram }}
Latency distribution:{{ range .LatencyDistribution }}
{{ .Percentage }}%% in {{ formatNumber .Latency.Seconds }} ms{{ end }}
{{ .Percentage }}%% in {{ formatMilli .Latency.Seconds }} ms{{ end }}
Status code distribution:{{ range $code, $num := .StatusCodeDist }}
[{{ $code }}] {{ $num }} responses{{ end }}
{{ if gt (len .ErrorDist) 0 }}Error distribution:{{ range $err, $num := .ErrorDist }}
Expand All @@ -105,6 +110,6 @@ Status code distribution:{{ range $code, $num := .StatusCodeDist }}

csvTmpl = `
duration (ms),status,error{{ range $i, $v := .Details }}
{{ formatNumber .Latency.Seconds }},{{ .Status }},{{ .Error }}{{ end }}
{{ formatMilli .Latency.Seconds }},{{ .Status }},{{ .Error }}{{ end }}
`
)

0 comments on commit aa6de5e

Please sign in to comment.