Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display in table view to save screen #11

Open
wants to merge 1 commit into
base: PR_3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cartridge
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Cartridge.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion cmdline/cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
66 changes: 66 additions & 0 deletions cmdline/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <Enter> (or ctrl-c) to exit")
}
}