From d5092a14b37154197417764a286ac8e1514d70ab Mon Sep 17 00:00:00 2001 From: Tofel <20401585+Tofel@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:43:54 +0000 Subject: [PATCH] [Bot] Add automatically generated go documentation --- wasp/benchspy/direct.go | 2 ++ wasp/benchspy/loki.go | 5 +++++ wasp/benchspy/report.go | 11 +++++++++++ 3 files changed, 18 insertions(+) diff --git a/wasp/benchspy/direct.go b/wasp/benchspy/direct.go index b522b2b74..d5ee38ad0 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 type. func (g *DirectQueryExecutor) GeneratorName() string { return g.Generator.Cfg.GenName } diff --git a/wasp/benchspy/loki.go b/wasp/benchspy/loki.go index 4a6c0ed6c..d6204f968 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 the specified generator name, queries, and Loki configuration. +// This function is useful for setting up a query executor to interact with Loki for log data retrieval. 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. +// It is useful for identifying the source of results in reports or logs. func (l *LokiQueryExecutor) GeneratorName() string { return l.GeneratorNameString } diff --git a/wasp/benchspy/report.go b/wasp/benchspy/report.go index f09449afc..e5fbd99e7 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 retrieves and casts results from a query executor to a specified type. +// It returns a map of query names to their corresponding results, or an error if casting 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 successful results are returned. 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 processed. 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,9 @@ func CompareDirectWithThresholds(medianThreshold, p95Threshold, maxThreshold, er return len(errors) > 0, errors } +// PrintStandardDirectMetrics outputs a comparison of direct metrics between two reports. +// It displays the current and previous values along with the percentage difference for each metric, +// helping users to quickly assess performance changes across different generator configurations. func PrintStandardDirectMetrics(currentReport, previousReport *StandardReport) { currentResults := MustAllDirectResults(currentReport) previousResults := MustAllDirectResults(previousReport)