Skip to content

Commit 147e0b9

Browse files
committed
feat: add access to underlying measures
1 parent 9f7cfa8 commit 147e0b9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

measure/src/main/java/net/laprun/sustainability/power/measure/OngoingPowerMeasure.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,27 @@ public Duration duration() {
121121

122122
@Override
123123
public DoubleStream getMeasuresFor(int component) {
124+
final double[] measuresForComponent = getLiveMeasuresFor(component);
125+
if (measuresForComponent == null || measuresForComponent.length == 0) {
126+
return DoubleStream.empty();
127+
}
128+
return Arrays.stream(measuresForComponent, 0, samples);
129+
}
130+
131+
public double[] getLiveMeasuresFor(int component) {
124132
if (nonZeroComponents.get(component)) {
125-
return Arrays.stream(measures[component], 0, samples);
133+
return measures[component];
126134
} else {
127135
final var match = syntheticComponents.stream()
128136
.filter(rsc -> targetComponentExistsAndIsRecorder(component, rsc))
129137
.map(rsc -> (Recorder) rsc.syntheticComponent())
130138
.findFirst()
131139
.orElse(null);
132140
if (match != null) {
133-
return match.measures();
141+
return match.liveMeasures();
134142
}
135143
}
136-
return DoubleStream.empty();
144+
return new double[0];
137145
}
138146

139147
private static boolean targetComponentExistsAndIsRecorder(int component, RegisteredSyntheticComponent rsc) {

0 commit comments

Comments
 (0)