Skip to content

Commit a6127dc

Browse files
committed
Log fatal if energy stats calculation fail
1 parent 3b5cf6d commit a6127dc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

internal/cmd/perfcomp/energystatistics_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func createTestVectors(start1 int, stop1 int, step1 int, start2 int, stop2 int,
3131
}
3232

3333
func TestEnergyStatistics(t *testing.T) {
34-
3534
t.Run("similar distributions should have small e,t,h values ", func(t *testing.T) {
3635
x, y := createTestVectors(1, 100, 1, 1, 105, 1)
3736
e, tstat, h, _ := getEnergyStatistics(x, y)
@@ -96,5 +95,4 @@ func TestEnergyStatistics(t *testing.T) {
9695
assert.NotEqual(t, nil, err)
9796
assert.ErrorContains(t, err, "both inputs must be column vectors")
9897
})
99-
10098
}

internal/cmd/perfcomp/main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,12 @@ func getEnergyStatsForOneBenchmark(ctx context.Context, rd RawData, coll *mongo.
256256

257257
estat, tstat, hscore, err := getEnergyStatistics(stableRegionVec, measValVec)
258258
if err != nil {
259-
return nil, fmt.Errorf("Could not calculate energy stats for test %q, measurement %q: %v", testname, measName, err)
259+
log.Fatalf(
260+
"Could not calculate energy stats for test %q, measurement %q: %v",
261+
testname,
262+
measName,
263+
err,
264+
)
260265
}
261266

262267
zscore := getZScore(measVal, stableRegion.Mean, stableRegion.Std)
@@ -286,7 +291,11 @@ func getEnergyStatsForAllBenchMarks(ctx context.Context, patchRawData []RawData,
286291
for _, rd := range patchRawData {
287292
energyStats, err := getEnergyStatsForOneBenchmark(ctx, rd, coll)
288293
if err != nil {
289-
log.Printf("%v\n", err) // Even if energy calculation for one benchmark fails, we still want to show the ones that passed.
294+
log.Fatalf(
295+
"Could not get energy stats for %q: %v",
296+
rd.Info.TestName,
297+
err,
298+
)
290299
} else {
291300
allEnergyStats = append(allEnergyStats, energyStats...)
292301
}

0 commit comments

Comments
 (0)