Tabnine Logo
TimeUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
TimeUtils
in
org.sonar.api.utils

Best Java code snippets using org.sonar.api.utils.TimeUtils (Showing top 11 results out of 315)

origin: SonarSource/sonarqube

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());
 }
}
origin: SonarSource/sonarqube

 @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");
 }
}
origin: SonarSource/sonarqube

 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");
  }
 }
}
origin: org.sonarsource.sonarqube/sonar-batch

public String totalTimeAsString() {
 return TimeUtils.formatDuration(totalTime);
}
origin: org.codehaus.sonar/sonar-batch

public String totalTimeAsString() {
 return TimeUtils.formatDuration(totalTime);
}
origin: org.sonarsource.sonarqube/sonar-db

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());
 }
}
origin: org.sonarsource.sonarqube/sonar-server

 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");
  }
 }
}
origin: org.codehaus.sonar/sonar-batch

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);
}
origin: org.sonarsource.sonarqube/sonar-batch

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);
}
origin: org.sonarsource.sonarqube/sonar-batch

@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();
  }
 }
}
origin: org.codehaus.sonar/sonar-batch

@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();
  }
 }
}
org.sonar.api.utilsTimeUtils

Most used methods

  • formatDuration
    Label for a duration, expressed in numbers of ms, seconds or minutes. Examples: * 10 -> "10ms" * 10

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • compareTo (BigDecimal)
  • startActivity (Activity)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Permission (java.security)
    Legacy security code; do not use.
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now