Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* @param components an array recording the power consumption reported by each component of this sensor
* @param tick the ordinal tick associated with this measure
*/
public record SensorMeasure(double[] components, long tick) {
public record SensorMeasure(double[] components, long tick, long timestamp, long duration) {
/**
* Represents an invalid or somehow missed measure.
*/
public static final SensorMeasure missing = new SensorMeasure(new double[] { -1.0 }, -1);
public static final SensorMeasure missing = new SensorMeasure(new double[] { -1.0 }, -1, -1, -1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ public boolean isStarted() {

@Override
public Measures update(Long tick) {
final long start = System.currentTimeMillis();
final var measure = new double[raplFiles.length];
for (int i = 0; i < raplFiles.length; i++) {
final var value = raplFiles[i].extractEnergyInMicroJoules();
final var newComponentValue = computePowerInMilliWatt(i, value);
measure[i] = newComponentValue;
lastMeasuredSensorValues[i] = newComponentValue;
}
measures.singleMeasure(new SensorMeasure(measure, tick));
final long timestamp = System.currentTimeMillis();
measures.singleMeasure(new SensorMeasure(measure, tick, timestamp, timestamp - start));
return measures;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public ProcessRecord(String line) throws IllegalArgumentException {
}

Measures extractPowerMeasure(InputStream powerMeasureInput, Long tick) {
final long start = System.currentTimeMillis();
try {
// Should not be closed since it closes the process
BufferedReader input = new BufferedReader(new InputStreamReader(powerMeasureInput));
Expand Down Expand Up @@ -196,7 +197,8 @@ Measures extractPowerMeasure(InputStream powerMeasureInput, Long tick) {
}
});

measures.record(pid, new SensorMeasure(measure, tick));
final long timestamp = System.currentTimeMillis();
measures.record(pid, new SensorMeasure(measure, tick, timestamp, timestamp - start));
});
} catch (Exception exception) {
throw new RuntimeException(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void start(long samplingFrequencyInMillis) {

@Override
public Measures update(Long tick) {
measures.trackedPIDs().forEach(pid -> measures.record(pid, new SensorMeasure(new double[] { Math.random() }, tick)));
measures.trackedPIDs().forEach(pid -> measures.record(pid,
new SensorMeasure(new double[] { Math.random() }, tick, System.currentTimeMillis(), 0)));
return measures;
}
}