Skip to content

Commit 92fc624

Browse files
committed
feat: encapsulate timing information from which to get cursors
1 parent 147e0b9 commit 92fc624

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ public synchronized TimestampedMeasures getNthTimestampedMeasures(int n) {
158158
return new TimestampedMeasures(timestamps[n], result);
159159
}
160160

161-
public Cursor.PartialCursor getCursorOver(long timestamp, Duration duration) {
162-
return Cursor.cursorOver(timestamps, timestamp, duration, startedAt, samplePeriod);
161+
public Timing timingInfo() {
162+
final var result = new long[timestamps.length];
163+
System.arraycopy(timestamps, 0, result, 0, timestamps.length);
164+
return new Timing(result, startedAt, samplePeriod);
163165
}
164166
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.laprun.sustainability.power.measure;
2+
3+
import java.time.Duration;
4+
5+
public record Timing(long[] timestamps, long startedAt, long samplePeriod) {
6+
public PartialCursor cursorOver(long timestamp, Duration duration) {
7+
return Cursor.cursorOver(timestamps, timestamp, duration, startedAt, samplePeriod);
8+
}
9+
}

0 commit comments

Comments
 (0)