Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

Dump all latencies in csv mode.

Burcu Dogan82956dc6a9a8
diff --git a/commands/print.go b/commands/print.go
index 2e31fa5..109c79e 100644
--- a/commands/print.go
+++ b/commands/print.go
@@ -70,27 +70,27 @@ func (r *report) print() {
if len(r.lats) > 0 {
sort.Float64s(r.lats)
- if r.output == "" {
- r.fastest = r.lats[0]
- r.slowest = r.lats[len(r.lats)-1]
- fmt.Printf("\nSummary:\n")
- fmt.Printf(" Total:\t%4.4f secs.\n", r.total.Seconds())
- fmt.Printf(" Slowest:\t%4.4f secs.\n", r.slowest)
- fmt.Printf(" Fastest:\t%4.4f secs.\n", r.fastest)
- fmt.Printf(" Average:\t%4.4f secs.\n", r.average)
- fmt.Printf(" Requests/sec:\t%4.4f\n", r.rps)
- r.printStatusCodes()
- r.printHistogram()
- r.printLatencies()
- } else if r.output == "csv" {
+ if r.output == "csv" {
r.printCSV()
+ return
}
+ r.fastest = r.lats[0]
+ r.slowest = r.lats[len(r.lats)-1]
+ fmt.Printf("\nSummary:\n")
+ fmt.Printf(" Total:\t%4.4f secs.\n", r.total.Seconds())
+ fmt.Printf(" Slowest:\t%4.4f secs.\n", r.slowest)
+ fmt.Printf(" Fastest:\t%4.4f secs.\n", r.fastest)
+ fmt.Printf(" Average:\t%4.4f secs.\n", r.average)
+ fmt.Printf(" Requests/sec:\t%4.4f\n", r.rps)
+ r.printStatusCodes()
+ r.printHistogram()
+ r.printLatencies()
}
}
func (r *report) printCSV() {
- for i := 0; i < 100; i++ {
- fmt.Printf("%v,%4.4f\n", i+1, r.lats[i*len(r.lats)/100])
+ for i, val := range r.lats {
+ fmt.Printf("%v,%4.4f\n", i+1, val)
}
}
diff --git a/commands/run.go b/commands/run.go
index 022b5ab..4a972c0 100644
--- a/commands/run.go
+++ b/commands/run.go
@@ -44,7 +44,7 @@ func (b *Boom) worker(ch chan bool) {
// cleanup body, so the socket can be reusable
resp.Body.Close()
}
- if b.Output == "" {
+ if b.bar != nil {
b.bar.Increment()
}
b.results <- &result{
@@ -84,7 +84,7 @@ func (b *Boom) run() {
close(jobs)
wg.Wait()
- if b.Output == "" {
+ if b.bar != nil {
b.bar.Finish()
}
b.rpt.finalize(time.Now().Sub(start))