Skip to content

Commit 56239d2

Browse files
committed
chore: unit test regressors to match estimator results
Signed-off-by: Huamin Chen <[email protected]>
1 parent 6f4ff7e commit 56239d2

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2021.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package regressor
18+
19+
import (
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
22+
23+
"github.com/sustainable-computing-io/kepler/pkg/model/types"
24+
)
25+
26+
var _ = Describe("Test Regressor Weight Unit (logarithm model from URL)", func() {
27+
It("Get Node Components Power By Logarithmic Regression with model from URL", func() {
28+
modelURL := "https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-db/refs/heads/main/models/v0.7/ec2-0.7.11/rapl-sysfs/AbsPower/BPFOnly/LogarithmicRegressionTrainer_0.json"
29+
30+
// Initialize the regressor with the URL
31+
r := genRegressor(types.AbsPower, types.ComponentEnergySource, "", modelURL, "", types.LogarithmicTrainer)
32+
err := r.Start()
33+
Expect(err).To(BeNil())
34+
35+
r.ResetSampleIdx()
36+
r.AddNodeFeatureValues(nodeFeatureValues)
37+
38+
powers, err := r.GetComponentsPower(false)
39+
Expect(err).NotTo(HaveOccurred())
40+
Expect(len(powers)).Should(Equal(1))
41+
42+
// Test power calculation. The results should match those from estimator
43+
// Expect(powers[0].Core).Should(BeNumerically("=", 0))
44+
// Expect(powers[0].DRAM).Should(BeNumerically("=", 0))
45+
// Expect(powers[0].Pkg).Should(BeNumerically("=", 0))
46+
47+
idlePowers, err := r.GetComponentsPower(true)
48+
Expect(err).NotTo(HaveOccurred())
49+
Expect(len(idlePowers)).Should(Equal(1))
50+
})
51+
})

0 commit comments

Comments
 (0)