|
6 | 6 | "github.com/HdrHistogram/hdrhistogram-go"
|
7 | 7 | "io/ioutil"
|
8 | 8 | "log"
|
| 9 | + "math" |
9 | 10 | "os"
|
10 | 11 | "sync"
|
11 | 12 | "sync/atomic"
|
@@ -63,6 +64,12 @@ type TestResult struct {
|
63 | 64 | // Overall Graph Internal Quantiles
|
64 | 65 | OverallGraphInternalLatencies map[string]interface{} `json:"OverallGraphInternalLatencies"`
|
65 | 66 |
|
| 67 | + // Relative Internal External Latencies Differences |
| 68 | + RelativeInternalExternalLatencyDiff map[string]float64 `json:"OverallRelativeInternalExternalLatencyDiff"` |
| 69 | + |
| 70 | + // Relative Internal External Latencies Differences |
| 71 | + AbsoluteInternalExternalLatencyDiff map[string]float64 `json:"OverallAbsoluteInternalExternalLatencyDiff"` |
| 72 | + |
66 | 73 | // Per second ( tick ) client stats
|
67 | 74 | ClientRunTimeStats map[int64]interface{} `json:"ClientRunTimeStats"`
|
68 | 75 |
|
@@ -188,15 +195,33 @@ func generateLatenciesMap(hist *hdrhistogram.Histogram) (int64, map[string]float
|
188 | 195 | return ops, mp
|
189 | 196 | }
|
190 | 197 |
|
191 |
| -func GetOverallLatencies(cmds []string, perQueryHistograms []*hdrhistogram.Histogram, totalsHistogram *hdrhistogram.Histogram) map[string]interface{} { |
| 198 | +func GetOverallLatencies(cmds []string, perQueryHistograms []*hdrhistogram.Histogram, totalsHistogram *hdrhistogram.Histogram) (map[string]interface{}, map[string]float64) { |
192 | 199 | perQueryQuantileMap := map[string]interface{}{}
|
193 | 200 | for i, query := range cmds {
|
194 | 201 | _, quantileMap := generateLatenciesMap(perQueryHistograms[i])
|
195 | 202 | perQueryQuantileMap[query] = quantileMap
|
196 | 203 | }
|
197 | 204 | _, totalMap := generateLatenciesMap(totalsHistogram)
|
198 | 205 | perQueryQuantileMap["Total"] = totalMap
|
199 |
| - return perQueryQuantileMap |
| 206 | + return perQueryQuantileMap, totalMap |
| 207 | +} |
| 208 | + |
| 209 | +func GenerateInternalExternalRatioLatencies(internal map[string]float64, external map[string]float64) (ratioMap map[string]float64, absoluteMap map[string]float64) { |
| 210 | + ratioMap = map[string]float64{} |
| 211 | + absoluteMap = map[string]float64{} |
| 212 | + for quantile, internalQuantileValue := range internal { |
| 213 | + |
| 214 | + externalQuantileValue := external[quantile] |
| 215 | + absoluteDiff := externalQuantileValue - internalQuantileValue |
| 216 | + relativeDiff := externalQuantileValue / internalQuantileValue |
| 217 | + if !math.IsNaN(relativeDiff) { |
| 218 | + ratioMap[quantile] = relativeDiff |
| 219 | + } |
| 220 | + if !math.IsNaN(absoluteDiff) { |
| 221 | + absoluteMap[quantile] = absoluteDiff |
| 222 | + } |
| 223 | + } |
| 224 | + return |
200 | 225 | }
|
201 | 226 |
|
202 | 227 | func GetOverallRatesMap(took time.Duration, cmds []string, perQueryHistograms []*hdrhistogram.Histogram, totalsHistogram *hdrhistogram.Histogram) map[string]interface{} {
|
|
0 commit comments