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

  • Finding current android device location
  • setContentView (Activity)
  • startActivity (Activity)
  • compareTo (BigDecimal)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • JPanel (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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