Skip to content
Merged
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
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ require (
github.com/RedisGraph/redisgraph-go v1.0.1-0.20210122150500-aa0feaa960ce
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/go-cmp v0.5.4 // indirect
github.com/mitchellh/gox v1.0.1 // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/stretchr/testify v1.7.0 // indirect
github.com/tcnksm/ghr v0.13.0 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
)
51 changes: 47 additions & 4 deletions redisgraph-bechmark-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func main() {
if len(benchmarkQueries) < 1 {
log.Fatalf("You need to specify at least a query with the -query parameter. For example: -query=\"CREATE (n)\"")
}
fmt.Printf("Debug level: %d.\n", *debug)
fmt.Printf("Using random seed: %d.\n", *randomSeed)
log.Printf("Debug level: %d.\n", *debug)
log.Printf("Using random seed: %d.\n", *randomSeed)
rand.Seed(*randomSeed)
testResult := NewTestResult("", uint(*clients), *numberRequests, uint64(*rps), "")
testResult.SetUsedRandomSeed(*randomSeed)
Expand All @@ -60,9 +60,9 @@ func main() {
// a WaitGroup for the goroutines to tell us they've stopped
wg := sync.WaitGroup{}
if !*loop {
fmt.Printf("Total clients: %d. Commands per client: %d Total commands: %d\n", *clients, samplesPerClient, *numberRequests)
log.Printf("Total clients: %d. Commands per client: %d Total commands: %d\n", *clients, samplesPerClient, *numberRequests)
} else {
fmt.Printf("Running in loop until you hit Ctrl+C\n")
log.Printf("Running in loop until you hit Ctrl+C\n")
}
queries := make([]string, len(benchmarkQueries))
cmdRates := make([]float64, len(benchmarkQueries))
Expand All @@ -84,6 +84,16 @@ func main() {
c1 := make(chan os.Signal, 1)
signal.Notify(c1, os.Interrupt)

graphC, _ := getStandaloneConn(*graphKey, "tcp", connectionStr, *password)
log.Printf("Trying to extract RedisGraph version info\n")

redisgraphVersion, err := getRedisGraphVersion(graphC)
if err != nil {
log.Println(fmt.Sprintf("Unable to retrieve RedisGraph version. Continuing anayway. Error: %v\n", err))
} else {
log.Println(fmt.Sprintf("Detected RedisGraph version %d\n", redisgraphVersion))
}

tick := time.NewTicker(time.Duration(client_update_tick) * time.Second)

dataPointProcessingWg.Add(1)
Expand Down Expand Up @@ -116,6 +126,7 @@ func main() {
testResult.OverallGraphInternalLatencies = GetOverallLatencies(queries, serverSide_PerQuery_GraphInternalTime_OverallLatencies, serverSide_AllQueries_GraphInternalTime_OverallLatencies)
testResult.OverallClientLatencies = GetOverallLatencies(queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies)
testResult.OverallQueryRates = GetOverallRatesMap(duration, queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies)
testResult.DBSpecificConfigs = GetDBConfigsMap(redisgraphVersion)
testResult.Totals = GetTotalsMap(queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies, errorsPerQuery, totalNodesCreatedPerQuery, totalNodesDeletedPerQuery, totalLabelsAddedPerQuery, totalPropertiesSetPerQuery, totalRelationshipsCreatedPerQuery, totalRelationshipsDeletedPerQuery)

// final merge of pending stats
Expand All @@ -125,3 +136,35 @@ func main() {
saveJsonResult(testResult, jsonOutputFile)
}
}

func GetDBConfigsMap(version int64) map[string]interface{} {
dbConfigsMap := map[string]interface{}{}
dbConfigsMap["RedisGraphVersion"] = version
return dbConfigsMap
}

// getRedisGraphVersion returns RedisGraph version by issuing "MODULE LIST" command
// and iterating through the availabe modules up until "graph" is found as the name property
func getRedisGraphVersion(graphClient redisgraph.Graph) (version int64, err error) {
var values []interface{}
var moduleInfo []interface{}
var moduleName string
values, err = redis.Values(graphClient.Conn.Do("MODULE", "LIST"))
if err != nil {
return
}
for _, rawModule := range values {
moduleInfo, err = redis.Values(rawModule, err)
if err != nil {
return
}
moduleName, err = redis.String(moduleInfo[1], err)
if err != nil {
return
}
if moduleName == "graph" {
version, err = redis.Int64(moduleInfo[3], err)
}
}
return
}
2 changes: 1 addition & 1 deletion test_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func saveJsonResult(testResult *TestResult, jsonOutputFile *string) {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Saving JSON results file to %s\n", *jsonOutputFile)
log.Printf("Saving JSON results file to %s\n", *jsonOutputFile)
err = ioutil.WriteFile(*jsonOutputFile, file, 0644)
if err != nil {
log.Fatal(err)
Expand Down