Skip to content

Commit

Permalink
[Bot] Add automatically generated go documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel authored and github-actions[bot] committed Dec 18, 2024
1 parent f5e1c5a commit ae420d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions wasp/benchspy/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions wasp/benchspy/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions wasp/benchspy/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ae420d0

Please sign in to comment.