diff --git a/Cartridge b/Cartridge index 7a7013d..b17df3e 100644 --- a/Cartridge +++ b/Cartridge @@ -8,3 +8,4 @@ github.com/cloudfoundry/gosteno origin/master github.com/onsi/ginkgo origin/master github.com/onsi/gomega origin/master github.com/go-yaml/yaml origin/master +github.com/crackcomm/go-clitable origin/master diff --git a/Cartridge.lock b/Cartridge.lock index 40a45cc..6bab8b5 100644 --- a/Cartridge.lock +++ b/Cartridge.lock @@ -8,3 +8,4 @@ github.com/cloudfoundry/gosteno 5eb8c6e554f0dfc39d6468813b8ac19ec28fe74f github.com/onsi/ginkgo 32204a3eab0576cbea19f5ff8b27d3a928647ea6 github.com/onsi/gomega a78ae492d53aad5a7a232d0d0462c14c400e3ee7 github.com/go-yaml/yaml 53feefa2559fb8dfa8d81baad31be332c97d6c77 +github.com/crackcomm/go-clitable 8ddbe7cde501fa7e2919965c4c5e628791a8d1a6 diff --git a/cmdline/cmdline.go b/cmdline/cmdline.go index ede1ded..a29f479 100644 --- a/cmdline/cmdline.go +++ b/cmdline/cmdline.go @@ -74,7 +74,7 @@ func RunCommandLine() error { handlers := make([]func(<-chan *Sample), 0) if !params.silent { handlers = append(handlers, func(s <-chan *Sample) { - display(params.concurrency, params.iterations, params.interval, params.stop, params.concurrencyStepTime, s) + display_table(params.concurrency, params.iterations, params.interval, params.stop, params.concurrencyStepTime, s) }) } diff --git a/cmdline/display.go b/cmdline/display.go index 960c855..9618ce0 100644 --- a/cmdline/display.go +++ b/cmdline/display.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/cloudfoundry-incubator/pat/experiment" + . "github.com/crackcomm/go-clitable" ) func display(concurrency string, iterations int, interval int, stop int, concurrencyStepTime int, samples <-chan *experiment.Sample) { @@ -66,3 +67,68 @@ func bar(n int64, total int64, size int) (bar string) { progress := int64(size) / (total / n) return "╞" + strings.Repeat("═", int(progress)) + strings.Repeat("┄", size-int(progress)) + "╡" } + +func display_table(concurrency string, iterations int, interval int, stop int, concurrencyStepTime int, samples <-chan *experiment.Sample) { + lastErrors := make(map[string]int) + totalError := 0 + for s := range samples { + fmt.Print("\033[2J\033[;H") + fmt.Println("\x1b[32;1mCloud Foundry Performance Acceptance Tests\x1b[0m") + fmt.Printf("Test underway. Concurrency: \x1b[36m%v\x1b[0m Concurrency:TimeBetwenSteps: \x1b[36m%v\x1b[0m Workload iterations: \x1b[36m%v\x1b[0m Interval: \x1b[36m%v\x1b[0m Stop: \x1b[36m%v\x1b[0m\n", + concurrency, concurrencyStepTime, iterations, interval, stop) + fmt.Println("┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄\n") + + fmt.Printf("\x1b[36mTotal iterations\x1b[0m: %v \x1b[36m%v\x1b[0m / %v\n", bar(s.Total, totalIterations(iterations, interval, stop), 25), s.Total, totalIterations(iterations, interval, stop)) + + fmt.Println() + table := New([]string{"Latest iteration", "Worst iteration", "Average iteration", "Average iteration", "95th Percentile", "Total time", "Wall time", "Running Workers"}) + table.AddRow(map[string]interface{}{ + "Latest iteration": s.LastResult, + "Worst iteration": s.WorstResult, + "Average iteration": s.Average, + "95th Percentile": s.NinetyfifthPercentile, + "Total time": s.TotalTime, + "Wall time": s.WallTime, + "Running Workers": s.TotalWorkers, + }) + table.Markdown = true + table.Print() + fmt.Println() + fmt.Println("\x1b[32;1mCommands Issued:\x1b[0m") + fmt.Println() + tableCmd := New([]string{"Key", "Count", "Average", "Last time", "Worst time", "Total time", "Per second throughput"}) + for key, command := range s.Commands { + tableCmd.AddRow(map[string]interface{}{ + "Key": key, + "Count": command.Count, + "Average": command.Average, + "Last time": command.LastTime, + "Worst time": command.WorstTime, + "Total time": command.TotalTime, + "Per second throughput": command.Throughput, + }) + } + tableCmd.Markdown = true + tableCmd.Print() + fmt.Println("┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄") + if s.TotalErrors > totalError { + totalError = s.TotalErrors + if _, ok := lastErrors[s.LastError]; ok { + lastErrors[s.LastError] += 1 + } else { + lastErrors[s.LastError] = 1 + } + } + tableError := New([]string{"Error desc", "Count"}) + for desc, count := range lastErrors { + tableError.AddRow(map[string]interface{}{ + "Error desc": desc, + "Count": count, + }) + } + tableError.Markdown = true + tableError.Print() + fmt.Println() + fmt.Println("Type q (or ctrl-c) to exit") + } +}