From ae420d082ef050138d675deb6e7cea921014b04d Mon Sep 17 00:00:00 2001 From: Tofel <20401585+Tofel@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:37:49 +0000 Subject: [PATCH] [Bot] Add automatically generated go documentation --- wasp/benchspy/direct.go | 2 ++ wasp/benchspy/loki.go | 5 +++++ wasp/benchspy/report.go | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/wasp/benchspy/direct.go b/wasp/benchspy/direct.go index b522b2b74..23653081c 100644 --- a/wasp/benchspy/direct.go +++ b/wasp/benchspy/direct.go @@ -49,6 +49,8 @@ func NewDirectQueryExecutor(generator *wasp.Generator, queries map[string]Direct return g, nil } +// GeneratorName returns the name of the generator associated with the query executor. +// It is useful for identifying and categorizing results based on their generator source. func (g *DirectQueryExecutor) GeneratorName() string { return g.Generator.Cfg.GenName } diff --git a/wasp/benchspy/loki.go b/wasp/benchspy/loki.go index 4a6c0ed6c..12ecdcf44 100644 --- a/wasp/benchspy/loki.go +++ b/wasp/benchspy/loki.go @@ -23,6 +23,9 @@ var ( Loki_ErrorRate = `sum(max_over_time({branch=~"%s", commit=~"%s", go_test_name=~"%s", test_data_type=~"stats", gen_name=~"%s"} | json| unwrap failed [%s]) by (node_id, go_test_name, gen_name)) by (__stream_shard__)` ) +// NewLokiQueryExecutor creates a new LokiQueryExecutor instance. +// It initializes the executor with a generator name, a set of queries, +// and Loki configuration, enabling efficient querying of logs in a decentralized environment. func NewLokiQueryExecutor(generatorName string, queries map[string]string, lokiConfig *wasp.LokiConfig) *LokiQueryExecutor { return &LokiQueryExecutor{ KindName: string(StandardQueryExecutor_Loki), @@ -49,6 +52,8 @@ type LokiQueryExecutor struct { Config *wasp.LokiConfig `json:"-"` } +// GeneratorName returns the name of the generator associated with the LokiQueryExecutor. +// This function is useful for identifying the source of query results in reporting contexts. func (l *LokiQueryExecutor) GeneratorName() string { return l.GeneratorNameString } diff --git a/wasp/benchspy/report.go b/wasp/benchspy/report.go index f09449afc..cbf33a608 100644 --- a/wasp/benchspy/report.go +++ b/wasp/benchspy/report.go @@ -40,6 +40,8 @@ func (b *StandardReport) LoadLatest(testName string) error { return b.LocalStorage.Load(testName, "", b) } +// ResultsAs converts query results from a QueryExecutor to a specified type. +// It returns a map of query names to their corresponding results, or an error if type conversion fails. func ResultsAs[Type any](newType Type, queryExecutor QueryExecutor, queryNames ...string) (map[string]Type, error) { results := make(map[string]Type) @@ -74,6 +76,8 @@ func ResultsAs[Type any](newType Type, queryExecutor QueryExecutor, queryNames . type LokiResultsByGenerator map[string]map[string][]string +// MustAllLokiResults retrieves and aggregates results from all Loki query executors in a StandardReport. +// It panics if any query execution fails, ensuring that only valid results are returned for further processing. func MustAllLokiResults(sr *StandardReport) LokiResultsByGenerator { results := make(LokiResultsByGenerator) @@ -94,6 +98,8 @@ func MustAllLokiResults(sr *StandardReport) LokiResultsByGenerator { type DirectResultsByGenerator map[string]map[string]float64 +// MustAllDirectResults extracts and returns all direct results from a given StandardReport. +// It panics if any result extraction fails, ensuring that only valid results are returned for further analysis. func MustAllDirectResults(sr *StandardReport) DirectResultsByGenerator { results := make(DirectResultsByGenerator) @@ -144,6 +150,8 @@ func calculateDiffPercentage(current, previous float64) float64 { return diffPrecentage } +// CompareDirectWithThresholds evaluates the current and previous reports against specified thresholds. +// It checks for significant differences in metrics and returns any discrepancies found, aiding in performance analysis. func CompareDirectWithThresholds(medianThreshold, p95Threshold, maxThreshold, errorRateThreshold float64, currentReport, previousReport *StandardReport) (bool, map[string][]error) { allCurrentResults := MustAllDirectResults(currentReport) allPreviousResults := MustAllDirectResults(previousReport) @@ -207,6 +215,8 @@ func CompareDirectWithThresholds(medianThreshold, p95Threshold, maxThreshold, er return len(errors) > 0, errors } +// PrintStandardDirectMetrics outputs a comparison of direct metrics between two reports. +// It displays the metrics along with their values and percentage differences, aiding in performance analysis. func PrintStandardDirectMetrics(currentReport, previousReport *StandardReport) { currentResults := MustAllDirectResults(currentReport) previousResults := MustAllDirectResults(previousReport)