From bcd707446af17e74185debaa3737a3d58edd60cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Senart?= Date: Thu, 12 Sep 2013 04:55:29 +0100 Subject: [PATCH] Report: Accept multiple input files In order to report results from multiple attack runs, the report sub command now accepts multiple input files. For you to run a distributed attack, use a tool like pdsh to run vegeta attack on different machines and then aggregate the results into one machine where vegeta report would consume them. --- report.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/report.go b/report.go index e428e7b..6644b70 100644 --- a/report.go +++ b/report.go @@ -4,12 +4,13 @@ import ( "flag" vegeta "github.com/tsenart/vegeta/lib" "log" + "strings" ) func reportCmd(args []string) command { fs := flag.NewFlagSet("report", flag.ExitOnError) reporter := fs.String("reporter", "text", "Reporter [text, json, plot:timings]") - input := fs.String("input", "stdin", "Input file") + input := fs.String("input", "stdin", "Input files (comma separated)") output := fs.String("output", "stdout", "Output file") fs.Parse(args) @@ -34,11 +35,19 @@ func report(reporter, input, output string) error { rep = vegeta.ReportText } - in, err := file(input, false) - if err != nil { - return err + all := vegeta.Results{} + for _, input := range strings.Split(input, ",") { + in, err := file(input, false) + if err != nil { + return err + } + defer in.Close() + results := vegeta.Results{} + if err := results.ReadFrom(in); err != nil { + return err + } + all = append(all, results...) } - defer in.Close() out, err := file(output, true) if err != nil { @@ -46,12 +55,7 @@ func report(reporter, input, output string) error { } defer out.Close() - results := vegeta.Results{} - if err := results.ReadFrom(in); err != nil { - return err - } - - if err := rep(results, out); err != nil { + if err := rep(all.Sort(), out); err != nil { return err }