finished csv reporter support

This commit is contained in:
Senad Uka
2013-11-07 12:12:39 +00:00
parent 681a7f2d02
commit de85e8709a
3 changed files with 15 additions and 15 deletions

View File

@@ -85,9 +85,9 @@ func csvString(d time.Duration) string {
} }
func(m *Metrics) Csv(rate uint64) []string { func(m *Metrics) Csv(rate uint64) []string {
result := fmt.Sprintf("%d req/s,%s,%s,%s,%s,%f,%f,%f",rate, result := fmt.Sprintf("%d req/s,%s,%s,%s,%s,%f,%f,%.2f",rate,
csvString(m.Latencies.Mean), csvString(m.Latencies.P95), csvString(m.Latencies.P99), csvString(m.Latencies.Max), csvString(m.Latencies.Mean), csvString(m.Latencies.P95), csvString(m.Latencies.P99), csvString(m.Latencies.Max),
m.BytesIn.Mean, m.BytesOut.Mean, m.Success) m.BytesIn.Mean, m.BytesOut.Mean, m.Success * 100)
return strings.Split(result, ",") return strings.Split(result, ",")
} }

View File

@@ -93,18 +93,18 @@ var plotsTemplate = `<!doctype>
type ResultGroup struct { type ResultGroup struct {
from uint64 from int
to uint64 to int
rate uint64 rate uint64
} }
func ReportCSV(results []Result) ([]byte, error) { func ReportCSV(results []Result) ([]byte, error) {
out := &bytes.Buffer{} out := &bytes.Buffer{}
m := NewMetrics(results)
// result := fnmt.Sprintf("%d req/s,%s,%s,%s,%s,%f,%f,%f",rate, // result := fnmt.Sprintf("%d req/s,%s,%s,%s,%s,%f,%f,%f",rate,
// m.Latencies.Mean.CsvString(), m.Latencies.P95.CsvString(), m.Latencies.P99.CsvString(), m.Latencies.Max.CsvString(), // m.Latencies.Mean.CsvString(), m.Latencies.P95.CsvString(), m.Latencies.P99.CsvString(), m.Latencies.Max.CsvString(),
// m.BytesIn.Mean, m.BytesOut.Mean, m.Success) // m.BytesIn.Mean, m.BytesOut.Mean, m.Success)
header := []string{ "rate" , "mean" , "p95", "p99" , "max", "bytesIn", "bytesOut", "success" } header := []string{ "rate" , "mean_ms" , "p95_ms", "p99_ms" , "max_ms", "bytesIn_B", "bytesOut_B", "success_percent" }
w := csv.NewWriter(out) w := csv.NewWriter(out)
w.Write(header) w.Write(header)
@@ -132,24 +132,24 @@ func slicesPerAttackRate(results []Result) ([]ResultGroup) {
if len(results) > 0 { if len(results) > 0 {
resultGroup := new(ResultGroup) resultGroup := ResultGroup{}
resultGroup.from = 0 resultGroup.from = 0
resultGroup.to = 0 resultGroup.to = 0
resultGroup.rate = results[0].rate resultGroup.rate = results[0].Rate
for i, result := range results { for i, result := range results {
if result.rate != resultGroup.rate { if result.Rate != resultGroup.rate {
resultGroup.to = i resultGroup.to = i
append(resultGroups, resultGroup) resultGroups = append(resultGroups, resultGroup)
resultGroup = new(ResultGroup) resultGroup = ResultGroup{}
resultGroup.from = i resultGroup.from = i
resultGroup.rate = result.rate resultGroup.rate = result.Rate
} }
} }
resultGroup.to = len(results) resultGroup.to = len(results)
append(resultGroups, resultGroup) resultGroups = append(resultGroups, resultGroup)
} }

View File

@@ -2,14 +2,14 @@ package main
import ( import (
"flag" "flag"
vegeta "github.com/tsenart/vegeta/lib" vegeta "github.com/senaduka/vegeta/lib"
"log" "log"
"strings" "strings"
) )
func reportCmd(args []string) command { func reportCmd(args []string) command {
fs := flag.NewFlagSet("report", flag.ExitOnError) fs := flag.NewFlagSet("report", flag.ExitOnError)
reporter := fs.String("reporter", "text", "Reporter [text, json, plot]") reporter := fs.String("reporter", "text", "Reporter [text, json, plot, csv]")
input := fs.String("input", "stdin", "Input files (comma separated)") input := fs.String("input", "stdin", "Input files (comma separated)")
output := fs.String("output", "stdout", "Output file") output := fs.String("output", "stdout", "Output file")
fs.Parse(args) fs.Parse(args)