diff --git a/quesma/quesma/ui/ab_testing.go b/quesma/quesma/ui/ab_testing.go
index 893842eb1..5f2c2a511 100644
--- a/quesma/quesma/ui/ab_testing.go
+++ b/quesma/quesma/ui/ab_testing.go
@@ -10,6 +10,7 @@ import (
"quesma/elasticsearch"
"quesma/jsondiff"
"quesma/logger"
+ "quesma/quesma/config"
"quesma/quesma/ui/internal/builder"
"strings"
"time"
@@ -75,7 +76,6 @@ If the performance gain is positive, it means that the second backend connector
buffer.Html(``)
buffer.Html(`
`)
@@ -86,7 +86,7 @@ If the performance gain is positive, it means that the second backend connector
buffer.Html(`
A/B Testing results are not available.
`) + buffer.Html(`CR results are not available.
`) } buffer.Html("\n\n\n") @@ -258,17 +258,19 @@ func formatJSON(in *string) string { } type abTestingReportRow struct { - dashboardId string - panelId string - dashboardUrl string - detailsUrl string - dashboardName string - panelName string - aName string - bName string - successRate *float64 - performanceGain *float64 - count int + dashboardId string + panelId string + dashboardUrl string + detailsUrl string + dashboardName string + panelName string + aName string + bName string + aTime *float64 + bTime *float64 + successRate *float64 + responseTimeDelta *float64 + count int } func (qmc *QuesmaManagementConsole) abTestingReadReport(kibanaUrl, orderBy string) ([]abTestingReportRow, error) { @@ -281,7 +283,6 @@ func (qmc *QuesmaManagementConsole) abTestingReadReport(kibanaUrl, orderBy strin orderByToSQL := map[string]string{ "default": "dashboard_id, panel_id, a_name, b_name", "response_similarity": "response_similarity DESC, dashboard_id, panel_id, a_name, b_name", - "performance_gain": "performance_gain DESC,dashboard_id, panel_id, a_name, b_name", "count": "count DESC,dashboard_id, panel_id, a_name, b_name", } @@ -311,8 +312,10 @@ SELECT a_name, b_name, (sumIf(c,ok)/ sum(c)) * 100 as response_similarity, - ((avgIf(a_time,ok)- avgIf(b_time,ok))/avgIf(a_time,ok))*100.0 as performance_gain, - sum(c) as count + + sum(c) as count, + avgIf(a_time,ok) as a_time, + avgIf(b_time,ok) as b_time FROM subresults GROUP BY @@ -331,7 +334,7 @@ GROUP BY for rows.Next() { row := abTestingReportRow{} - err := rows.Scan(&row.dashboardId, &row.panelId, &row.aName, &row.bName, &row.successRate, &row.performanceGain, &row.count) + err := rows.Scan(&row.dashboardId, &row.panelId, &row.aName, &row.bName, &row.successRate, &row.count, &row.aTime, &row.bTime) if err != nil { return nil, err } @@ -341,6 +344,26 @@ GROUP BY row.dashboardName = kibanaDashboards.dashboardName(row.dashboardId) row.panelName = kibanaDashboards.panelName(row.dashboardId, row.panelId) + if row.aTime != nil && row.bTime != nil { + + var clickhouseTime, elasticTime float64 + + if row.aName == config.ElasticsearchTarget { + elasticTime = *row.aTime + clickhouseTime = *row.bTime + } else { + elasticTime = *row.bTime + clickhouseTime = *row.aTime + } + + if elasticTime == 0 { + row.responseTimeDelta = nil + } else { + delta := (elasticTime - clickhouseTime) / elasticTime * 100 + row.responseTimeDelta = &delta + } + } + result = append(result, row) } @@ -361,7 +384,7 @@ func (qmc *QuesmaManagementConsole) generateABTestingReport(kibanaUrl, orderBy s buffer.Html(`