Skip to content

Commit

Permalink
feat: output measure duration
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Oct 23, 2023
1 parent 24613ec commit e3d221c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class AppleSiliconMeasure implements PowerSensor.Measure {
private double gpu;
private double ane;
private int samplesNb;
private final long startedAt = System.currentTimeMillis();

public static final String ANE = "ane";

Expand Down Expand Up @@ -56,4 +57,9 @@ public int numberOfSamples() {
void incrementSamples() {
samplesNb++;
}

@Override
public long measureDuration() {
return System.currentTimeMillis() - startedAt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public AppleSiliconMeasure stop() {
@Override
public void outputConsumptionSinceStarted(Writer out) {
out = out == null ? System.out::println : out;
out.println("Consumed " + accumulatedPower.total() + " mW");
out.println("Consumed " + accumulatedPower.total() + " mW over " + (accumulatedPower.measureDuration() / 1000)
+ " seconds");
}

private void stop(Writer out) {
Expand Down

0 comments on commit e3d221c

Please sign in to comment.