Skip to content

Commit 617e0c7

Browse files
committed
[add] Made query ratios fractional. [add] Included average on the overall latencies map
1 parent 02c9d6c commit 617e0c7

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (i *arrayStringParameters) Set(value string) error {
2020
return nil
2121
}
2222

23-
func printFinalSummary(queries []string, queryRates []int, totalMessages uint64, duration time.Duration) {
23+
func printFinalSummary(queries []string, queryRates []float64, totalMessages uint64, duration time.Duration) {
2424
writer := os.Stdout
2525
messageRate := float64(totalMessages) / float64(duration.Seconds())
2626

multi-query.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,26 @@ func sample(cdf []float32) int {
1515
return bucket
1616
}
1717

18-
func prepareCommandsDistribution(cmds []string, cmdRates []int) (int, []float32) {
19-
var totalRates int = 0
18+
func prepareCommandsDistribution(cmds []string, cmdRates []float64) (int, []float32) {
2019
var totalDifferentCommands = len(cmds)
20+
var totalRateSum = 0.0
2121
var err error
2222
for i, rawCmdString := range benchmarkQueries {
2323
cmds[i] = rawCmdString
2424
if i >= len(benchmarkQueryRates) {
2525
cmdRates[i] = 1
2626

2727
} else {
28-
cmdRates[i], err = strconv.Atoi(benchmarkQueryRates[i])
28+
cmdRates[i], err = strconv.ParseFloat(benchmarkQueryRates[i], 64)
2929
if err != nil {
3030
log.Fatalf("Error while converting query-rate param %s: %v", benchmarkQueryRates[i], err)
3131
}
3232
}
33-
totalRates += cmdRates[i]
33+
totalRateSum += cmdRates[i]
34+
}
35+
// probability density function
36+
if totalRateSum != 1.0 {
37+
log.Fatalf("Total ratio should be 1.0 ( currently is %f )", totalRateSum)
3438
}
3539
// probability density function
3640
if len(benchmarkQueryRates) > 0 && (len(benchmarkQueryRates) != len(benchmarkQueries)) {
@@ -39,7 +43,7 @@ func prepareCommandsDistribution(cmds []string, cmdRates []int) (int, []float32)
3943
pdf := make([]float32, len(benchmarkQueries))
4044
cdf := make([]float32, len(benchmarkQueries))
4145
for i := 0; i < len(cmdRates); i++ {
42-
pdf[i] = float32(cmdRates[i]) / float32(totalRates)
46+
pdf[i] = float32(cmdRates[i])
4347
cdf[i] = 0
4448
}
4549
// get cdf

redisgraph-bechmark-go.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func main() {
6565
fmt.Printf("Running in loop until you hit Ctrl+C\n")
6666
}
6767
queries := make([]string, len(benchmarkQueries))
68-
cmdRates := make([]int, len(benchmarkQueries))
68+
cmdRates := make([]float64, len(benchmarkQueries))
6969
totalDifferentCommands, cdf := prepareCommandsDistribution(queries, cmdRates)
7070

7171
createRequiredGlobalStructs(totalDifferentCommands)
@@ -113,8 +113,8 @@ func main() {
113113
testResult.FillDurationInfo(startTime, endTime, duration)
114114
testResult.BenchmarkFullyRun = totalCommands == *numberRequests
115115
testResult.IssuedCommands = totalCommands
116-
testResult.OverallGraphInternalQuantiles = GetOverallQuantiles(queries, serverSide_PerQuery_GraphInternalTime_OverallLatencies, serverSide_AllQueries_GraphInternalTime_OverallLatencies)
117-
testResult.OverallClientQuantiles = GetOverallQuantiles(queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies)
116+
testResult.OverallGraphInternalLatencies = GetOverallLatencies(queries, serverSide_PerQuery_GraphInternalTime_OverallLatencies, serverSide_AllQueries_GraphInternalTime_OverallLatencies)
117+
testResult.OverallClientLatencies = GetOverallLatencies(queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies)
118118
testResult.OverallQueryRates = GetOverallRatesMap(duration, queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies)
119119
testResult.Totals = GetTotalsMap(queries, clientSide_PerQuery_OverallLatencies, clientSide_AllQueries_OverallLatencies, errorsPerQuery, totalNodesCreatedPerQuery, totalNodesDeletedPerQuery, totalLabelsAddedPerQuery, totalPropertiesSetPerQuery, totalRelationshipsCreatedPerQuery, totalRelationshipsDeletedPerQuery)
120120

test_result.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ type TestResult struct {
5858
OverallQueryRates map[string]interface{} `json:"OverallQueryRates"`
5959

6060
// Overall Client Quantiles
61-
OverallClientQuantiles map[string]interface{} `json:"OverallClientQuantiles"`
61+
OverallClientLatencies map[string]interface{} `json:"OverallClientLatencies"`
6262

6363
// Overall Graph Internal Quantiles
64-
OverallGraphInternalQuantiles map[string]interface{} `json:"OverallGraphInternalQuantiles"`
64+
OverallGraphInternalLatencies map[string]interface{} `json:"OverallGraphInternalLatencies"`
6565

6666
// Per second ( tick ) client stats
6767
ClientRunTimeStats map[int64]interface{} `json:"ClientRunTimeStats"`
@@ -165,34 +165,36 @@ func calculateRateMetrics(current, prev int64, took time.Duration) (rate float64
165165
return
166166
}
167167

168-
func generateQuantileMap(hist *hdrhistogram.Histogram) (int64, map[string]float64) {
168+
func generateLatenciesMap(hist *hdrhistogram.Histogram) (int64, map[string]float64) {
169169
ops := hist.TotalCount()
170170
q0 := 0.0
171171
q50 := 0.0
172172
q95 := 0.0
173173
q99 := 0.0
174174
q999 := 0.0
175175
q100 := 0.0
176+
average := 0.0
176177
if ops > 0 {
177178
q0 = float64(hist.ValueAtQuantile(0.0)) / 10e2
178179
q50 = float64(hist.ValueAtQuantile(50.0)) / 10e2
179180
q95 = float64(hist.ValueAtQuantile(95.0)) / 10e2
180181
q99 = float64(hist.ValueAtQuantile(99.0)) / 10e2
181182
q999 = float64(hist.ValueAtQuantile(99.90)) / 10e2
182183
q100 = float64(hist.ValueAtQuantile(100.0)) / 10e2
184+
average = (hist.Mean() / float64(1000.0))
183185
}
184186

185-
mp := map[string]float64{"q0": q0, "q50": q50, "q95": q95, "q99": q99, "q999": q999, "q100": q100}
187+
mp := map[string]float64{"q0": q0, "q50": q50, "q95": q95, "q99": q99, "q999": q999, "q100": q100, "avg": average}
186188
return ops, mp
187189
}
188190

189-
func GetOverallQuantiles(cmds []string, perQueryHistograms []*hdrhistogram.Histogram, totalsHistogram *hdrhistogram.Histogram) map[string]interface{} {
191+
func GetOverallLatencies(cmds []string, perQueryHistograms []*hdrhistogram.Histogram, totalsHistogram *hdrhistogram.Histogram) map[string]interface{} {
190192
perQueryQuantileMap := map[string]interface{}{}
191193
for i, query := range cmds {
192-
_, quantileMap := generateQuantileMap(perQueryHistograms[i])
194+
_, quantileMap := generateLatenciesMap(perQueryHistograms[i])
193195
perQueryQuantileMap[query] = quantileMap
194196
}
195-
_, totalMap := generateQuantileMap(totalsHistogram)
197+
_, totalMap := generateLatenciesMap(totalsHistogram)
196198
perQueryQuantileMap["Total"] = totalMap
197199
return perQueryQuantileMap
198200
}

0 commit comments

Comments
 (0)