From de85e8709a07ea2b42082d171be980e66c7fe586 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Thu, 7 Nov 2013 12:12:39 +0000 Subject: [PATCH] finished csv reporter support --- lib/metrics.go | 4 ++-- lib/reporters.go | 22 +++++++++++----------- report.go | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/metrics.go b/lib/metrics.go index 2967fdf..e5ea889 100644 --- a/lib/metrics.go +++ b/lib/metrics.go @@ -85,9 +85,9 @@ func csvString(d time.Duration) 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), - m.BytesIn.Mean, m.BytesOut.Mean, m.Success) + m.BytesIn.Mean, m.BytesOut.Mean, m.Success * 100) return strings.Split(result, ",") } diff --git a/lib/reporters.go b/lib/reporters.go index f65b658..e4dae2a 100644 --- a/lib/reporters.go +++ b/lib/reporters.go @@ -93,18 +93,18 @@ var plotsTemplate = ` type ResultGroup struct { - from uint64 - to uint64 + from int + to int rate uint64 } func ReportCSV(results []Result) ([]byte, error) { out := &bytes.Buffer{} - m := NewMetrics(results) + // 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.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.Write(header) @@ -132,24 +132,24 @@ func slicesPerAttackRate(results []Result) ([]ResultGroup) { if len(results) > 0 { - resultGroup := new(ResultGroup) + resultGroup := ResultGroup{} resultGroup.from = 0 resultGroup.to = 0 - resultGroup.rate = results[0].rate + resultGroup.rate = results[0].Rate for i, result := range results { - if result.rate != resultGroup.rate { + if result.Rate != resultGroup.rate { resultGroup.to = i - append(resultGroups, resultGroup) - resultGroup = new(ResultGroup) + resultGroups = append(resultGroups, resultGroup) + resultGroup = ResultGroup{} resultGroup.from = i - resultGroup.rate = result.rate + resultGroup.rate = result.Rate } } resultGroup.to = len(results) - append(resultGroups, resultGroup) + resultGroups = append(resultGroups, resultGroup) } diff --git a/report.go b/report.go index 614fa2b..59e63e3 100644 --- a/report.go +++ b/report.go @@ -2,14 +2,14 @@ package main import ( "flag" - vegeta "github.com/tsenart/vegeta/lib" + vegeta "github.com/senaduka/vegeta/lib" "log" "strings" ) func reportCmd(args []string) command { 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)") output := fs.String("output", "stdout", "Output file") fs.Parse(args)