Skip to content

Commit 2a4bec4

Browse files
Enhance startup summary, refine workload triggers
1 parent dd9c73b commit 2a4bec4

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

cmd/genMongoLoad/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func main() {
186186
// -----------------------------------------------------------------------------------
187187
// PRINT BANNER / CONFIGURATION
188188
// -----------------------------------------------------------------------------------
189-
stats.PrintConfiguration(appCfg, dbName, version)
189+
stats.PrintConfiguration(appCfg, collectionsCfg.Collections, version)
190190

191191
// --- Connect to DB ---
192192
conn, err := db.Connect(ctx, appCfg, dbName)

internal/stats/collector.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func NewCollector() *Collector {
9797
}
9898
}
9999

100-
func PrintConfiguration(appCfg *config.AppConfig, dbName string, version string) {
100+
func PrintConfiguration(appCfg *config.AppConfig, collections []config.CollectionDefinition, version string) {
101101
fmt.Println()
102102
fmt.Printf(" %s\n", logger.CyanString("genMongoLoad %s", version))
103103
fmt.Println(logger.CyanString(" --------------------------------------------------"))
@@ -139,8 +139,28 @@ func PrintConfiguration(appCfg *config.AppConfig, dbName string, version string)
139139
w.Flush()
140140
fmt.Println()
141141

142+
// Logic to extract unique DBs and Namespaces
143+
uniqueDBs := make(map[string]bool)
144+
var namespaces []string
145+
for _, col := range collections {
146+
uniqueDBs[col.DatabaseName] = true
147+
namespaces = append(namespaces, fmt.Sprintf("%s.%s", col.DatabaseName, col.Name))
148+
}
149+
150+
var dbs []string
151+
for db := range uniqueDBs {
152+
dbs = append(dbs, db)
153+
}
154+
sort.Strings(dbs)
155+
sort.Strings(namespaces)
156+
142157
w = tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
143-
fmt.Fprintf(w, " Database:\t%s\n", dbName)
158+
159+
// Display Namespaces
160+
if len(namespaces) > 0 {
161+
fmt.Fprintf(w, " Namespaces:\t%s\n", strings.Join(namespaces, ", "))
162+
}
163+
144164
fmt.Fprintf(w, " Workers:\t%d active\n", appCfg.Concurrency)
145165
fmt.Fprintf(w, " Duration:\t%s\n", appCfg.Duration)
146166
fmt.Fprintf(w, " Report Freq:\t%ds\n", appCfg.StatusRefreshRateSec)

0 commit comments

Comments
 (0)