@@ -37,8 +37,8 @@ func main() {
3737 if len (benchmarkQueries ) < 1 {
3838 log .Fatalf ("You need to specify at least a query with the -query parameter. For example: -query=\" CREATE (n)\" " )
3939 }
40- fmt .Printf ("Debug level: %d.\n " , * debug )
41- fmt .Printf ("Using random seed: %d.\n " , * randomSeed )
40+ log .Printf ("Debug level: %d.\n " , * debug )
41+ log .Printf ("Using random seed: %d.\n " , * randomSeed )
4242 rand .Seed (* randomSeed )
4343 testResult := NewTestResult ("" , uint (* clients ), * numberRequests , uint64 (* rps ), "" )
4444 testResult .SetUsedRandomSeed (* randomSeed )
@@ -60,9 +60,9 @@ func main() {
6060 // a WaitGroup for the goroutines to tell us they've stopped
6161 wg := sync.WaitGroup {}
6262 if ! * loop {
63- fmt .Printf ("Total clients: %d. Commands per client: %d Total commands: %d\n " , * clients , samplesPerClient , * numberRequests )
63+ log .Printf ("Total clients: %d. Commands per client: %d Total commands: %d\n " , * clients , samplesPerClient , * numberRequests )
6464 } else {
65- fmt .Printf ("Running in loop until you hit Ctrl+C\n " )
65+ log .Printf ("Running in loop until you hit Ctrl+C\n " )
6666 }
6767 queries := make ([]string , len (benchmarkQueries ))
6868 cmdRates := make ([]float64 , len (benchmarkQueries ))
@@ -84,6 +84,16 @@ func main() {
8484 c1 := make (chan os.Signal , 1 )
8585 signal .Notify (c1 , os .Interrupt )
8686
87+ graphC , _ := getStandaloneConn (* graphKey , "tcp" , connectionStr , * password )
88+ log .Printf ("Trying to extract RedisGraph version info\n " )
89+
90+ redisgraphVersion , err := getRedisGraphVersion (graphC )
91+ if err != nil {
92+ log .Println (fmt .Sprintf ("Unable to retrieve RedisGraph version. Continuing anayway. Error: %v\n " , err ))
93+ } else {
94+ log .Println (fmt .Sprintf ("Detected RedisGraph version %d\n " , redisgraphVersion ))
95+ }
96+
8797 tick := time .NewTicker (time .Duration (client_update_tick ) * time .Second )
8898
8999 dataPointProcessingWg .Add (1 )
@@ -116,6 +126,7 @@ func main() {
116126 testResult .OverallGraphInternalLatencies = GetOverallLatencies (queries , serverSide_PerQuery_GraphInternalTime_OverallLatencies , serverSide_AllQueries_GraphInternalTime_OverallLatencies )
117127 testResult .OverallClientLatencies = GetOverallLatencies (queries , clientSide_PerQuery_OverallLatencies , clientSide_AllQueries_OverallLatencies )
118128 testResult .OverallQueryRates = GetOverallRatesMap (duration , queries , clientSide_PerQuery_OverallLatencies , clientSide_AllQueries_OverallLatencies )
129+ testResult .DBSpecificConfigs = GetDBConfigsMap (redisgraphVersion )
119130 testResult .Totals = GetTotalsMap (queries , clientSide_PerQuery_OverallLatencies , clientSide_AllQueries_OverallLatencies , errorsPerQuery , totalNodesCreatedPerQuery , totalNodesDeletedPerQuery , totalLabelsAddedPerQuery , totalPropertiesSetPerQuery , totalRelationshipsCreatedPerQuery , totalRelationshipsDeletedPerQuery )
120131
121132 // final merge of pending stats
@@ -125,3 +136,35 @@ func main() {
125136 saveJsonResult (testResult , jsonOutputFile )
126137 }
127138}
139+
140+ func GetDBConfigsMap (version int64 ) map [string ]interface {} {
141+ dbConfigsMap := map [string ]interface {}{}
142+ dbConfigsMap ["RedisGraphVersion" ] = version
143+ return dbConfigsMap
144+ }
145+
146+ // getRedisGraphVersion returns RedisGraph version by issuing "MODULE LIST" command
147+ // and iterating through the availabe modules up until "graph" is found as the name property
148+ func getRedisGraphVersion (graphClient redisgraph.Graph ) (version int64 , err error ) {
149+ var values []interface {}
150+ var moduleInfo []interface {}
151+ var moduleName string
152+ values , err = redis .Values (graphClient .Conn .Do ("MODULE" , "LIST" ))
153+ if err != nil {
154+ return
155+ }
156+ for _ , rawModule := range values {
157+ moduleInfo , err = redis .Values (rawModule , err )
158+ if err != nil {
159+ return
160+ }
161+ moduleName , err = redis .String (moduleInfo [1 ], err )
162+ if err != nil {
163+ return
164+ }
165+ if moduleName == "graph" {
166+ version , err = redis .Int64 (moduleInfo [3 ], err )
167+ }
168+ }
169+ return
170+ }
0 commit comments