fr.jcgay.maven.profiler.ArtifactDescriptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-profiler Show documentation
Show all versions of maven-profiler Show documentation
Log Maven mojos execution time
package fr.jcgay.maven.profiler;
import com.google.common.base.Stopwatch;
import org.eclipse.aether.artifact.Artifact;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.collect.Iterables.filter;
import static fr.jcgay.maven.profiler.KnownElapsedTimeTicker.aStopWatchWithElapsedTime;
public class ArtifactDescriptor {
private final Stopwatch totalStopwatch;
private ArtifactDescriptor(long totalTime) {
this.totalStopwatch = aStopWatchWithElapsedTime(totalTime);
}
public static ArtifactDescriptor instance(Map times) {
if (times == null || times.isEmpty()) {
return new ArtifactDescriptor(0);
}
return new ArtifactDescriptor(totalTime(times));
}
private static long totalTime(Map times) {
long totalTime = 0;
for (Stopwatch stopwatch : filter(times.values(), notNull())) {
totalTime += stopwatch.elapsedTime(TimeUnit.NANOSECONDS);
}
return totalTime;
}
public Stopwatch getTotalTimeSpentDownloadingArtifacts() {
return totalStopwatch;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy