@@ -25,13 +25,23 @@ type LatencyHistogram struct {
2525 Overflow int64
2626 Count int64
2727 Sum float64
28+ Min float64
29+ Max float64
2830}
2931
3032func (h * LatencyHistogram ) Record (ms float64 ) {
3133 h .mu .Lock ()
3234 defer h .mu .Unlock ()
3335 h .Count ++
3436 h .Sum += ms
37+
38+ if ms < h .Min {
39+ h .Min = ms
40+ }
41+ if ms > h .Max {
42+ h .Max = ms
43+ }
44+
3545 bucket := int (math .Round (ms ))
3646 if bucket < 0 {
3747 bucket = 0
@@ -88,15 +98,16 @@ type Collector struct {
8898
8999func NewCollector () * Collector {
90100 return & Collector {
91- FindHist : & LatencyHistogram {},
92- InsertHist : & LatencyHistogram {},
93- UpdateHist : & LatencyHistogram {},
94- DeleteHist : & LatencyHistogram {},
95- AggHist : & LatencyHistogram {},
101+ FindHist : & LatencyHistogram {Min : math . MaxFloat64 },
102+ InsertHist : & LatencyHistogram {Min : math . MaxFloat64 },
103+ UpdateHist : & LatencyHistogram {Min : math . MaxFloat64 },
104+ DeleteHist : & LatencyHistogram {Min : math . MaxFloat64 },
105+ AggHist : & LatencyHistogram {Min : math . MaxFloat64 },
96106 startTime : time .Now (),
97107 }
98108}
99109
110+ // CHANGED: Second argument is now []config.CollectionDefinition instead of dbName string
100111func PrintConfiguration (appCfg * config.AppConfig , collections []config.CollectionDefinition , version string ) {
101112 fmt .Println ()
102113 fmt .Printf (" %s\n " , logger .CyanString ("genMongoLoad %s" , version ))
@@ -139,28 +150,14 @@ func PrintConfiguration(appCfg *config.AppConfig, collections []config.Collectio
139150 w .Flush ()
140151 fmt .Println ()
141152
142- // Logic to extract unique DBs and Namespaces
143- uniqueDBs := make (map [string ]bool )
153+ // Logic to print Namespaces instead of just Database
144154 var namespaces []string
145155 for _ , col := range collections {
146- uniqueDBs [col .DatabaseName ] = true
147156 namespaces = append (namespaces , fmt .Sprintf ("%s.%s" , col .DatabaseName , col .Name ))
148157 }
149158
150- var dbs []string
151- for db := range uniqueDBs {
152- dbs = append (dbs , db )
153- }
154- sort .Strings (dbs )
155- sort .Strings (namespaces )
156-
157159 w = tabwriter .NewWriter (os .Stdout , 0 , 0 , 2 , ' ' , 0 )
158-
159- // Display Namespaces
160- if len (namespaces ) > 0 {
161- fmt .Fprintf (w , " Namespaces:\t %s\n " , strings .Join (namespaces , ", " ))
162- }
163-
160+ fmt .Fprintf (w , " Namespaces:\t %s\n " , strings .Join (namespaces , ", " )) // Changed from Database
164161 fmt .Fprintf (w , " Workers:\t %d active\n " , appCfg .Concurrency )
165162 fmt .Fprintf (w , " Duration:\t %s\n " , appCfg .Duration )
166163 fmt .Fprintf (w , " Report Freq:\t %ds\n " , appCfg .StatusRefreshRateSec )
@@ -303,11 +300,11 @@ func (c *Collector) PrintFinalSummary(duration time.Duration) {
303300 fmt .Println (logger .BoldString (" LATENCY DISTRIBUTION (ms)" ))
304301 fmt .Println (logger .CyanString (" --------------------------------------------------" ))
305302
306- const tableLayout = " %-7s %10s %10s %10s"
307- headerStr := fmt .Sprintf (tableLayout , "TYPE" , "AVG" , "P95" , "P99" )
303+ const tableLayout = " %-7s %10s %10s %10s %10s %10s "
304+ headerStr := fmt .Sprintf (tableLayout , "TYPE" , "AVG" , "MIN" , "MAX" , " P95" , "P99" )
308305 fmt .Println (logger .BoldString (headerStr ))
309306
310- separatorStr := fmt .Sprintf (tableLayout , "----" , "---" , "---" , "---" )
307+ separatorStr := fmt .Sprintf (tableLayout , "----" , "---" , "---" , "---" , "---" , "---" )
311308 fmt .Println (logger .CyanString (separatorStr ))
312309
313310 printLatencyRow (tableLayout , "SELECT" , c .FindHist )
@@ -320,14 +317,15 @@ func (c *Collector) PrintFinalSummary(duration time.Duration) {
320317
321318func printLatencyRow (layout string , label string , h * LatencyHistogram ) {
322319 if h .Count == 0 {
323- fmt .Printf (layout + "\n " , label , "-" , "-" , "-" )
320+ fmt .Printf (layout + "\n " , label , "-" , "-" , "-" , "-" , "-" )
324321 return
325322 }
326323 avgMs := h .Sum / float64 (h .Count )
327324 p95Ms := h .GetPercentile (95.0 )
328325 p99Ms := h .GetPercentile (99.0 )
329- fmt .Printf (layout + "\n " , label , formatLatency (avgMs ), formatLatency (p95Ms ), formatLatency (p99Ms ))
326+ fmt .Printf (layout + "\n " , label , formatLatency (avgMs ), formatLatency (h . Min ), formatLatency ( h . Max ), formatLatency ( p95Ms ), formatLatency (p99Ms ))
330327}
328+
331329func formatLatency (ms float64 ) string {
332330 if ms < 1000.0 {
333331 return fmt .Sprintf ("%.2f ms" , ms )
@@ -337,6 +335,7 @@ func formatLatency(ms float64) string {
337335 }
338336 return fmt .Sprintf ("%.2f m" , ms / 60000.0 )
339337}
338+
340339func formatInt (n int64 ) string {
341340 in := strconv .FormatInt (n , 10 )
342341 numOfDigits := len (in )
0 commit comments