more features
This commit is contained in:
@@ -505,38 +505,40 @@ func (sc *StatsCollector) printSummary() {
|
|||||||
|
|
||||||
// Print per-method statistics for ALL backends
|
// Print per-method statistics for ALL backends
|
||||||
if len(sc.backendMethodStats) > 0 {
|
if len(sc.backendMethodStats) > 0 {
|
||||||
fmt.Printf("\nPer-Method Backend Comparison:\n")
|
fmt.Printf("\nPer-Method Backend Comparison (Top 3 Methods):\n")
|
||||||
|
|
||||||
// Collect all unique methods across all backends
|
// Collect all unique methods across all backends with their total counts
|
||||||
allMethods := make(map[string]bool)
|
methodCounts := make(map[string]int)
|
||||||
for _, methods := range sc.backendMethodStats {
|
for _, methods := range sc.backendMethodStats {
|
||||||
for method := range methods {
|
for method, durations := range methods {
|
||||||
allMethods[method] = true
|
methodCounts[method] += len(durations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort methods for consistent output
|
// Sort methods by total count (descending)
|
||||||
var methodList []string
|
type methodCount struct {
|
||||||
for method := range allMethods {
|
method string
|
||||||
methodList = append(methodList, method)
|
count int
|
||||||
}
|
}
|
||||||
sort.Strings(methodList)
|
var methodList []methodCount
|
||||||
|
for method, count := range methodCounts {
|
||||||
|
methodList = append(methodList, methodCount{method, count})
|
||||||
|
}
|
||||||
|
sort.Slice(methodList, func(i, j int) bool {
|
||||||
|
return methodList[i].count > methodList[j].count
|
||||||
|
})
|
||||||
|
|
||||||
// For each method, show stats from all backends
|
// Only show top 3 methods
|
||||||
for _, method := range methodList {
|
maxMethods := 3
|
||||||
hasData := false
|
if len(methodList) < maxMethods {
|
||||||
for _, backend := range backendNames {
|
maxMethods = len(methodList)
|
||||||
if durations, exists := sc.backendMethodStats[backend][method]; exists && len(durations) > 0 {
|
}
|
||||||
hasData = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !hasData {
|
// For each of the top methods, show stats from all backends
|
||||||
continue
|
for i := 0; i < maxMethods; i++ {
|
||||||
}
|
method := methodList[i].method
|
||||||
|
|
||||||
fmt.Printf("\n Method: %s\n", method)
|
fmt.Printf("\n Method: %s (Total requests: %d)\n", method, methodList[i].count)
|
||||||
fmt.Printf(" %-20s %10s %10s %10s %10s %10s %10s %10s\n",
|
fmt.Printf(" %-20s %10s %10s %10s %10s %10s %10s %10s\n",
|
||||||
"Backend", "Count", "Min", "Avg", "Max", "p50", "p90", "p99")
|
"Backend", "Count", "Min", "Avg", "Max", "p50", "p90", "p99")
|
||||||
fmt.Printf(" %s\n", strings.Repeat("-", 98))
|
fmt.Printf(" %s\n", strings.Repeat("-", 98))
|
||||||
|
|||||||
Reference in New Issue
Block a user