You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
randomSeed:=flag.Int64("random-seed", 12345, "Random seed to use.")
30
+
dataImportFile:=flag.String("data-import-terms", "", "Read field replacement data from file in csv format. each column should start and end with '__' chars. Example __field1__,__field2__.")
31
+
dataImportMode:=flag.String("data-import-terms-mode", "seq", "Either 'seq' or 'rand'.")
29
32
randomIntMin:=flag.Int64("random-int-min", 1, "__rand_int__ lower value limit. __rand_int__ distribution is uniform Random")
30
33
randomIntMax:=flag.Int64("random-int-max", 1000000, "__rand_int__ upper value limit. __rand_int__ distribution is uniform Random")
flag.Var(&benchmarkQueries, "query", "Specify a RedisGraph query to send in quotes. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=1")
33
36
flag.Var(&benchmarkQueriesRO, "query-ro", "Specify a RedisGraph read-only query to send in quotes. You can run multiple commands (both read/write) on the same benchmark. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=0.5 -query-ro=\"MATCH (n) RETURN n\" -query-ratio=0.5")
34
37
flag.Var(&benchmarkQueryRates, "query-ratio", "The query ratio vs other queries used in the same benchmark. Each command that you specify is run with its ratio. For example: -query=\"CREATE (n)\" -query-ratio=0.5 -query=\"MATCH (n) RETURN n\" -query-ratio=0.5")
35
38
jsonOutputFile:=flag.String("json-out-file", "benchmark-results.json", "Name of json output file to output benchmark results. If not set, will not print to json.")
36
-
cliUpdateTick:=flag.Duration("reporting-period", time.Second*10, "Period to report stats.")
39
+
cliUpdateTick:=flag.Duration("reporting-period", time.Second*5, "Period to report stats.")
log.Printf("Reading term data import file from: %s. Using '%s' record read mode.\n", *dataImportFile, *dataImportMode)
115
+
dataReplacementEnabled=true
116
+
replacementArr=make([]map[string]string, 0)
117
+
118
+
f, err:=os.Open(*dataImportFile)
119
+
iferr!=nil {
120
+
log.Fatal("Unable to read input file "+*dataImportFile, err)
121
+
}
122
+
deferf.Close()
123
+
124
+
csvReader:=csv.NewReader(f)
125
+
records, err:=csvReader.ReadAll()
126
+
headers:=records[0]
127
+
rlen:=len(records) -1
128
+
fori:=0; i<int(*numberRequests); i++ {
129
+
// seq mode
130
+
recordPos:=i%rlen
131
+
ifstrings.Compare(*dataImportMode, "rand") ==0 {
132
+
recordPos=rand.Intn(rlen)
133
+
}
134
+
record:=records[recordPos+1]
135
+
lineMap:=make(map[string]string)
136
+
forj:=0; j<len(headers); j++ {
137
+
lineMap[headers[j]] =record[j]
138
+
}
139
+
replacementArr=append(replacementArr, lineMap)
140
+
}
141
+
iferr!=nil {
142
+
log.Fatal("Unable to parse file as CSV for "+*dataImportFile, err)
143
+
}
144
+
log.Printf("There are a total of %d disticint lines of terms. Each line has %d columns. Prepared %d groups of records for the benchmark.\n", rlen, len(headers), len(replacementArr))
0 commit comments