Skip to content

Commit daa74ec

Browse files
committed
microbench-ci: marker file utility function
This commit adds a utility function to generate the marker file name for a given benchmark and status. The marker file is used to indicate that a benchmark has changed. It is created for each metric of a benchmark. Epic: None Release note: None
1 parent 21a2ce4 commit daa74ec

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pkg/cmd/microbench-ci/benchmark.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func (b *Benchmark) sanitizedName() string {
5555
return sanitizeRe.ReplaceAllString(strings.TrimPrefix(b.Name, "Benchmark"), "_")
5656
}
5757

58+
func (b *Benchmark) markerName(status Status) string {
59+
return b.sanitizedName() + "." + strings.ToUpper(status.String())
60+
}
61+
5862
func (b *Benchmark) binaryName() string {
5963
return b.sanitizedPackageName()
6064
}

pkg/cmd/microbench-ci/run.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ func (b *Benchmark) run() error {
152152
// be written.
153153
for _, metric := range b.Metrics {
154154
if status[metric.Name] != NoChange {
155-
marker := strings.ToUpper(status[metric.Name].String())
156-
err := os.WriteFile(path.Join(suite.artifactsDir(New), b.sanitizedName()+"."+marker), nil, 0644)
155+
err := os.WriteFile(path.Join(suite.artifactsDir(New), b.markerName(status[metric.Name])), nil, 0644)
157156
if err != nil {
158157
return err
159158
}

0 commit comments

Comments
 (0)