@@ -40,6 +40,8 @@ func (b *StandardReport) LoadLatest(testName string) error {
4040 return b .LocalStorage .Load (testName , "" , b )
4141}
4242
43+ // ResultsAs converts query results from a QueryExecutor to a specified type.
44+ // It returns a map of query names to their corresponding results, or an error if type conversion fails.
4345func ResultsAs [Type any ](newType Type , queryExecutor QueryExecutor , queryNames ... string ) (map [string ]Type , error ) {
4446 results := make (map [string ]Type )
4547
@@ -74,6 +76,8 @@ func ResultsAs[Type any](newType Type, queryExecutor QueryExecutor, queryNames .
7476
7577type LokiResultsByGenerator map [string ]map [string ][]string
7678
79+ // MustAllLokiResults retrieves and aggregates results from all Loki query executors in a StandardReport.
80+ // It panics if any query execution fails, ensuring that only valid results are returned for further processing.
7781func MustAllLokiResults (sr * StandardReport ) LokiResultsByGenerator {
7882 results := make (LokiResultsByGenerator )
7983
@@ -94,6 +98,8 @@ func MustAllLokiResults(sr *StandardReport) LokiResultsByGenerator {
9498
9599type DirectResultsByGenerator map [string ]map [string ]float64
96100
101+ // MustAllDirectResults extracts and returns all direct results from a given StandardReport.
102+ // It panics if any result extraction fails, ensuring that only valid results are returned for further analysis.
97103func MustAllDirectResults (sr * StandardReport ) DirectResultsByGenerator {
98104 results := make (DirectResultsByGenerator )
99105
@@ -144,6 +150,8 @@ func calculateDiffPercentage(current, previous float64) float64 {
144150 return diffPrecentage
145151}
146152
153+ // CompareDirectWithThresholds evaluates the current and previous reports against specified thresholds.
154+ // It checks for significant differences in metrics and returns any discrepancies found, aiding in performance analysis.
147155func CompareDirectWithThresholds (medianThreshold , p95Threshold , maxThreshold , errorRateThreshold float64 , currentReport , previousReport * StandardReport ) (bool , map [string ][]error ) {
148156 allCurrentResults := MustAllDirectResults (currentReport )
149157 allPreviousResults := MustAllDirectResults (previousReport )
@@ -207,6 +215,8 @@ func CompareDirectWithThresholds(medianThreshold, p95Threshold, maxThreshold, er
207215 return len (errors ) > 0 , errors
208216}
209217
218+ // PrintStandardDirectMetrics outputs a comparison of direct metrics between two reports.
219+ // It displays the metrics along with their values and percentage differences, aiding in performance analysis.
210220func PrintStandardDirectMetrics (currentReport , previousReport * StandardReport ) {
211221 currentResults := MustAllDirectResults (currentReport )
212222 previousResults := MustAllDirectResults (previousReport )
0 commit comments