Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

Apply gofmt.

Mehmet Akinf3f167b5a39e
diff --git a/commands/print.go b/commands/print.go
index 3ede0e8..c81342a 100644
--- a/commands/print.go
+++ b/commands/print.go
@@ -16,8 +16,8 @@ package commands
import (
"fmt"
- "time"
"sort"
+ "time"
)
var statusCodeDist map[int]int = make(map[int]int)
@@ -51,11 +51,11 @@ func (b *Boom) Print() {
fmt.Printf(" Requests/sec:\t%4.4f\n", rps)
fmt.Printf(" Speed index:\t%v\n", speedIndex(rps))
// Calculate and print percentile latencies.
- pctls := []int{10,25,50,75,90,95,99};
- pctlLatencies := b.getLatencyPercentiles(pctls, latencies)
- fmt.Printf("\nLatency distribution:\n",)
- for i := 0; i < len(pctls); i++ {
- if pctlLatencies[i] > 0 {
+ pctls := []int{10, 25, 50, 75, 90, 95, 99}
+ pctlLatencies := b.getLatencyPercentiles(pctls, latencies)
+ fmt.Printf("\nLatency distribution:\n")
+ for i := 0; i < len(pctls); i++ {
+ if pctlLatencies[i] > 0 {
fmt.Printf(" %vth percentile: %4.4f\n", pctls[i], pctlLatencies[i])
}
}
@@ -67,18 +67,18 @@ func (b *Boom) Print() {
// Returns percentile latencies for given duration list.
func (b *Boom) getLatencyPercentiles(percentiles []int, latencies []float64) []float64 {
- // Sort the array
- sort.Float64s(latencies)
- var pctl []float64 = make([]float64, len(percentiles));
- var j int = 0;
- for i := 0; i < len(latencies) && j < len(percentiles); i++ {
- currentPercentile := (i + 1) * 100 / len(latencies)
- if currentPercentile >= percentiles[j] {
- pctl[j] = latencies[i]
- j++
- }
- }
- return pctl;
+ // Sort the array
+ sort.Float64s(latencies)
+ var pctl []float64 = make([]float64, len(percentiles))
+ var j int = 0
+ for i := 0; i < len(latencies) && j < len(percentiles); i++ {
+ currentPercentile := (i + 1) * 100 / len(latencies)
+ if currentPercentile >= percentiles[j] {
+ pctl[j] = latencies[i]
+ j++
+ }
+ }
+ return pctl
}
func (b *Boom) printStatusCodes() {