public void dump(long totalTime, Logger logger) { List<Entry<String, Long>> data = new ArrayList<>(durations.entrySet()); Collections.sort(data, (o1, o2) -> o2.getValue().compareTo(o1.getValue())); double percent = totalTime / 100.0; for (Entry<String, Long> entry : truncateList(data)) { StringBuilder sb = new StringBuilder(); sb.append(" o ").append(entry.getKey()).append(": ").append(TimeUtils.formatDuration(entry.getValue())) .append(" (").append((int) (entry.getValue() / percent)).append("%)"); logger.info(sb.toString()); } }
@Test public void formatDuration() { assertThat(TimeUtils.formatDuration(0)).isEqualTo("0ms"); assertThat(TimeUtils.formatDuration(100)).isEqualTo("100ms"); assertThat(TimeUtils.formatDuration(1000)).isEqualTo("1s"); assertThat(TimeUtils.formatDuration(10000)).isEqualTo("10s"); assertThat(TimeUtils.formatDuration(100000)).isEqualTo("1min 40s"); assertThat(TimeUtils.formatDuration(600000)).isEqualTo("10min"); assertThat(TimeUtils.formatDuration(1000000)).isEqualTo("16min 40s"); assertThat(TimeUtils.formatDuration(10000000)).isEqualTo("166min 40s"); } }
private void logProfiling(long start, Configuration config) { if (config.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY).orElse(false)) { long duration = System.currentTimeMillis() - start; LOG.info("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n"); profiler.dump(duration, LOG); LOG.info("\n -------- End of profiling for purge --------\n"); } } }
public String totalTimeAsString() { return TimeUtils.formatDuration(totalTime); }
public String totalTimeAsString() { return TimeUtils.formatDuration(totalTime); }
public void dump(long totalTime, Logger logger) { List<Entry<String, Long>> data = new ArrayList<>(durations.entrySet()); Collections.sort(data, (o1, o2) -> o2.getValue().compareTo(o1.getValue())); double percent = totalTime / 100.0; for (Entry<String, Long> entry : truncateList(data)) { StringBuilder sb = new StringBuilder(); sb.append(" o ").append(entry.getKey()).append(": ").append(TimeUtils.formatDuration(entry.getValue())) .append(" (").append((int) (entry.getValue() / percent)).append("%)"); logger.info(sb.toString()); } }
private void logProfiling(long start, Configuration config) { if (config.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY).orElse(false)) { long duration = System.currentTimeMillis() - start; LOG.info("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n"); profiler.dump(duration, LOG); LOG.info("\n -------- End of profiling for purge --------\n"); } } }
private void dumpTotalExecutionSummary() { totalProfiling.stop(); long totalTime = totalProfiling.totalTime(); println(""); println(" ======== Profiling of total execution: " + TimeUtils.formatDuration(totalTime) + " ========"); println(""); println(" * Module execution time breakdown: "); double percent = totalTime / 100.0; for (ModuleProfiling modulesProfiling : truncate(sortByDescendingTotalTime(modulesProfilings).values())) { println(" o " + modulesProfiling.moduleName() + " execution time: ", percent, modulesProfiling); } println(""); Properties props = new Properties(); totalProfiling.dump(props); println(""); println(" ======== End of profiling of total execution ========"); println(""); String fileName = "total-execution-profiler.properties"; dumpToFile(props, fileName); }
private void dumpTotalExecutionSummary() { totalProfiling.stop(); long totalTime = totalProfiling.totalTime(); println(""); println(" ======== Profiling of total execution: " + TimeUtils.formatDuration(totalTime) + " ========"); println(""); println(" * Module execution time breakdown: "); double percent = totalTime / 100.0; for (ModuleProfiling modulesProfiling : truncate(sortByDescendingTotalTime(modulesProfilings).values())) { println(" o " + modulesProfiling.moduleName() + " execution time: ", percent, modulesProfiling); } println(""); Properties props = new Properties(); totalProfiling.dump(props); println(""); println(" ======== End of profiling of total execution ========"); println(""); String fileName = "total-execution-profiler.properties"; dumpToFile(props, fileName); }
@Override public void onProjectAnalysis(ProjectAnalysisEvent event) { Project module = event.getProject(); if (event.isStart()) { decoratorsProfiler = new DecoratorsProfiler(); currentModuleProfiling = new ModuleProfiling(module, system); } else { currentModuleProfiling.stop(); modulesProfilings.put(module, currentModuleProfiling); long moduleTotalTime = currentModuleProfiling.totalTime(); println(""); println(" -------- Profiling of module " + module.getName() + ": " + TimeUtils.formatDuration(moduleTotalTime) + " --------"); println(""); Properties props = new Properties(); currentModuleProfiling.dump(props); println(""); println(" -------- End of profiling of module " + module.getName() + " --------"); println(""); String fileName = module.getKey() + "-profiler.properties"; dumpToFile(props, BatchUtils.cleanKeyForFilename(fileName)); totalProfiling.merge(currentModuleProfiling); if (module.isRoot() && !module.getModules().isEmpty()) { dumpTotalExecutionSummary(); } } }
@Override public void onProjectAnalysis(ProjectAnalysisEvent event) { Project module = event.getProject(); if (event.isStart()) { decoratorsProfiler = new DecoratorsProfiler(); currentModuleProfiling = new ModuleProfiling(module, system); } else { currentModuleProfiling.stop(); modulesProfilings.put(module, currentModuleProfiling); long moduleTotalTime = currentModuleProfiling.totalTime(); println(""); println(" -------- Profiling of module " + module.getName() + ": " + TimeUtils.formatDuration(moduleTotalTime) + " --------"); println(""); Properties props = new Properties(); currentModuleProfiling.dump(props); println(""); println(" -------- End of profiling of module " + module.getName() + " --------"); println(""); String fileName = module.getKey() + "-profiler.properties"; dumpToFile(props, BatchUtils.cleanKeyForFilename(fileName)); totalProfiling.merge(currentModuleProfiling); if (module.isRoot() && !module.getModules().isEmpty()) { dumpTotalExecutionSummary(); } } }