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

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

Best Java code snippets using org.sonar.api.utils.TimeUtils.formatDuration (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.utilsTimeUtilsformatDuration

Javadoc

Label for a duration, expressed in numbers of ms, seconds or minutes.
Examples:
  • 10 -> "10ms"
  • 100 -> "100ms"
  • 10000 -> "10s"
  • 100000 -> "1min 40s"

Popular methods of TimeUtils

    Popular in Java

    • Making http post requests using okhttp
    • orElseThrow (Optional)
      Return the contained value, if present, otherwise throw an exception to be created by the provided s
    • onCreateOptionsMenu (Activity)
    • getOriginalFilename (MultipartFile)
      Return the original filename in the client's filesystem.This may contain path information depending
    • BorderLayout (java.awt)
      A border layout lays out a container, arranging and resizing its components to fit in five regions:
    • Socket (java.net)
      Provides a client-side TCP socket.
    • LinkedList (java.util)
      Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
    • ConcurrentHashMap (java.util.concurrent)
      A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
    • Annotation (javassist.bytecode.annotation)
      The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
    • Cipher (javax.crypto)
      This class provides access to implementations of cryptographic ciphers for encryption and decryption
    • Best IntelliJ plugins
    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