Skip to content

Commit 987fee9

Browse files
[Bot] Add automatically generated go documentation (#1486)
Co-authored-by: Tofel <[email protected]>
1 parent 72e7370 commit 987fee9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

wasp/benchspy/direct.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func NewDirectQueryExecutor(generator *wasp.Generator, queries map[string]Direct
4949
return g, nil
5050
}
5151

52+
// GeneratorName returns the name of the generator associated with the query executor.
53+
// It is useful for identifying and categorizing results based on their generator type.
5254
func (g *DirectQueryExecutor) GeneratorName() string {
5355
return g.Generator.Cfg.GenName
5456
}

wasp/benchspy/loki.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ var (
2323
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__)`
2424
)
2525

26+
// NewLokiQueryExecutor creates a new LokiQueryExecutor instance.
27+
// It initializes the executor with the specified generator name, queries, and Loki configuration.
28+
// This function is useful for setting up a query executor to interact with Loki for log data retrieval.
2629
func NewLokiQueryExecutor(generatorName string, queries map[string]string, lokiConfig *wasp.LokiConfig) *LokiQueryExecutor {
2730
return &LokiQueryExecutor{
2831
KindName: string(StandardQueryExecutor_Loki),
@@ -49,6 +52,8 @@ type LokiQueryExecutor struct {
4952
Config *wasp.LokiConfig `json:"-"`
5053
}
5154

55+
// GeneratorName returns the name of the generator associated with the LokiQueryExecutor.
56+
// It is useful for identifying the source of results in reports or logs.
5257
func (l *LokiQueryExecutor) GeneratorName() string {
5358
return l.GeneratorNameString
5459
}

wasp/benchspy/report.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func (b *StandardReport) LoadLatest(testName string) error {
4040
return b.LocalStorage.Load(testName, "", b)
4141
}
4242

43+
// ResultsAs retrieves and casts results from a query executor to a specified type.
44+
// It returns a map of query names to their corresponding results, or an error if casting fails.
4345
func 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

7577
type 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 successful results are returned.
7781
func MustAllLokiResults(sr *StandardReport) LokiResultsByGenerator {
7882
results := make(LokiResultsByGenerator)
7983

@@ -94,6 +98,8 @@ func MustAllLokiResults(sr *StandardReport) LokiResultsByGenerator {
9498

9599
type 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 processed.
97103
func 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.
147155
func CompareDirectWithThresholds(medianThreshold, p95Threshold, maxThreshold, errorRateThreshold float64, currentReport, previousReport *StandardReport) (bool, map[string][]error) {
148156
allCurrentResults := MustAllDirectResults(currentReport)
149157
allPreviousResults := MustAllDirectResults(previousReport)
@@ -207,6 +215,9 @@ 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 current and previous values along with the percentage difference for each metric,
220+
// helping users to quickly assess performance changes across different generator configurations.
210221
func PrintStandardDirectMetrics(currentReport, previousReport *StandardReport) {
211222
currentResults := MustAllDirectResults(currentReport)
212223
previousResults := MustAllDirectResults(previousReport)

0 commit comments

Comments
 (0)