diff --git a/devtools/maven/src/main/java/io/quarkus/maven/BuildAnalyticsProvider.java b/devtools/maven/src/main/java/io/quarkus/maven/BuildAnalyticsProvider.java index ee33134dacba8..8ed5a399f7fcb 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/BuildAnalyticsProvider.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/BuildAnalyticsProvider.java @@ -5,6 +5,7 @@ import java.io.File; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import javax.inject.Inject; @@ -25,9 +26,9 @@ @Named public class BuildAnalyticsProvider { - private RuntimeInformation runtimeInformation; + private final RuntimeInformation runtimeInformation; - private AnalyticsService analyticsService; + private final AnalyticsService analyticsService; private Log log; @@ -41,18 +42,21 @@ public void sendAnalytics(TrackEventType trackEventType, ApplicationModel applicationModel, Map graalVMInfo, File localBuildDir) { - final long start = System.currentTimeMillis(); + final long start = System.nanoTime(); - final Map buildInfo = new HashMap<>(); - buildInfo.putAll(graalVMInfo); + final Map buildInfo = new HashMap<>(graalVMInfo); buildInfo.put(MAVEN_VERSION, runtimeInformation.getMavenVersion()); analyticsService.sendAnalytics(trackEventType, applicationModel, buildInfo, localBuildDir); if (getLog().isDebugEnabled()) { - getLog().debug("Analytics took " + (System.currentTimeMillis() - start) + "ms"); + getLog().debug("Analytics took " + (duration(System.nanoTime(), start)) + "ms"); } } + private long duration(long end, long start) { + return TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS); + } + public void buildAnalyticsUserInput(Function analyticsEnabledSupplier) { analyticsService.buildAnalyticsUserInput(analyticsEnabledSupplier); }