diff --git a/core/runtime/src/main/java/io/quarkus/runtime/util/StepTiming.java b/core/runtime/src/main/java/io/quarkus/runtime/util/StepTiming.java index 7d4f4b5c65d22..43142f2f39fc1 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/util/StepTiming.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/util/StepTiming.java @@ -3,6 +3,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; +import java.util.concurrent.TimeUnit; import io.quarkus.runtime.StartupContext; @@ -18,19 +19,22 @@ public static void configureEnabled() { } public static void configureStart() { - stepTimingStart = System.currentTimeMillis(); + stepTimingStart = System.nanoTime(); } public static void printStepTime(StartupContext startupContext) { if (!stepTimingEnabled) { return; } - long stepTimingStop = System.currentTimeMillis(); String currentBuildStepName = startupContext.getCurrentBuildStepName(); System.out.printf("%1$tF %1$tT,%1$tL Build step %2$s completed in: %3$sms%n", - LocalDateTime.ofInstant(Instant.ofEpochMilli(stepTimingStop), ZoneId.systemDefault()), + LocalDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()), ZoneId.systemDefault()), currentBuildStepName, - stepTimingStop - stepTimingStart); - stepTimingStart = System.currentTimeMillis(); + duration(System.nanoTime(), stepTimingStart)); + stepTimingStart = System.nanoTime(); + } + + private static long duration(long ended, long started) { + return TimeUnit.MILLISECONDS.convert(ended - started, TimeUnit.NANOSECONDS); } }