From e3d221c2744f1c5f52590d6d093e63ff5179e8e4 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Mon, 23 Oct 2023 18:55:16 +0200 Subject: [PATCH] feat: output measure duration --- .../io/quarkiverse/power/runtime/AppleSiliconMeasure.java | 6 ++++++ .../quarkiverse/power/runtime/MacOSPowermetricsSensor.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/src/main/java/io/quarkiverse/power/runtime/AppleSiliconMeasure.java b/runtime/src/main/java/io/quarkiverse/power/runtime/AppleSiliconMeasure.java index a3d1c00..3e282af 100644 --- a/runtime/src/main/java/io/quarkiverse/power/runtime/AppleSiliconMeasure.java +++ b/runtime/src/main/java/io/quarkiverse/power/runtime/AppleSiliconMeasure.java @@ -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"; @@ -56,4 +57,9 @@ public int numberOfSamples() { void incrementSamples() { samplesNb++; } + + @Override + public long measureDuration() { + return System.currentTimeMillis() - startedAt; + } } diff --git a/runtime/src/main/java/io/quarkiverse/power/runtime/MacOSPowermetricsSensor.java b/runtime/src/main/java/io/quarkiverse/power/runtime/MacOSPowermetricsSensor.java index ad11225..9a9568a 100644 --- a/runtime/src/main/java/io/quarkiverse/power/runtime/MacOSPowermetricsSensor.java +++ b/runtime/src/main/java/io/quarkiverse/power/runtime/MacOSPowermetricsSensor.java @@ -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) {