org.springframework.util.StopWatch.getTaskInfo()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.springframework.util.StopWatch.getTaskInfo()方法的一些代码示例,展示了StopWatch.getTaskInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.getTaskInfo()方法的具体详情如下:
包路径:org.springframework.util.StopWatch
类名称:StopWatch
方法名:getTaskInfo

StopWatch.getTaskInfo介绍

[英]Return an array of the data for tasks performed.
[中]返回所执行任务的数据数组。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return an informative string describing all tasks performed
 * For custom reporting, call {@code getTaskInfo()} and use the task info directly.
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(shortSummary());
  if (this.keepTaskList) {
    for (TaskInfo task : getTaskInfo()) {
      sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
      long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
      sb.append(" = ").append(percent).append("%");
    }
  }
  else {
    sb.append("; no task info kept");
  }
  return sb.toString();
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
  StringBuilder sb = new StringBuilder(shortSummary());
  sb.append('\n');
  if (!this.keepTaskList) {
    sb.append("No task info kept");
  }
  else {
    sb.append("-----------------------------------------\n");
    sb.append("ms     %     Task name\n");
    sb.append("-----------------------------------------\n");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);
    NumberFormat pf = NumberFormat.getPercentInstance();
    pf.setMinimumIntegerDigits(3);
    pf.setGroupingUsed(false);
    for (TaskInfo task : getTaskInfo()) {
      sb.append(nf.format(task.getTimeMillis())).append("  ");
      sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
      sb.append(task.getTaskName()).append("\n");
    }
  }
  return sb.toString();
}

代码示例来源:origin: org.springframework/spring-core

/**
 * Return an informative string describing all tasks performed
 * For custom reporting, call {@code getTaskInfo()} and use the task info directly.
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(shortSummary());
  if (this.keepTaskList) {
    for (TaskInfo task : getTaskInfo()) {
      sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
      long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
      sb.append(" = ").append(percent).append("%");
    }
  }
  else {
    sb.append("; no task info kept");
  }
  return sb.toString();
}

代码示例来源:origin: org.springframework/spring-core

/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
  StringBuilder sb = new StringBuilder(shortSummary());
  sb.append('\n');
  if (!this.keepTaskList) {
    sb.append("No task info kept");
  }
  else {
    sb.append("-----------------------------------------\n");
    sb.append("ms     %     Task name\n");
    sb.append("-----------------------------------------\n");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);
    NumberFormat pf = NumberFormat.getPercentInstance();
    pf.setMinimumIntegerDigits(3);
    pf.setGroupingUsed(false);
    for (TaskInfo task : getTaskInfo()) {
      sb.append(nf.format(task.getTimeMillis())).append("  ");
      sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
      sb.append(task.getTaskName()).append("\n");
    }
  }
  return sb.toString();
}

代码示例来源:origin: spring-projects/spring-framework

sw.getTaskInfo();

代码示例来源:origin: spring-projects/spring-framework

assertTrue(pp.contains(name2));
StopWatch.TaskInfo[] tasks = sw.getTaskInfo();
assertTrue(tasks.length == 2);
assertTrue(tasks[0].getTaskName().equals(name1));

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Return an informative string describing all tasks performed
 * For custom reporting, call <code>getTaskInfo()</code> and use the task info directly.
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(shortSummary());
  if (this.keepTaskList) {
    for (TaskInfo task : getTaskInfo()) {
      sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
      long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
      sb.append(" = ").append(percent).append("%");
    }
  } else {
    sb.append("; no task info kept");
  }
  return sb.toString();
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
  StringBuilder sb = new StringBuilder(shortSummary());
  sb.append('\n');
  if (!this.keepTaskList) {
    sb.append("No task info kept");
  } else {
    sb.append("-----------------------------------------\n");
    sb.append("ms     %     Task name\n");
    sb.append("-----------------------------------------\n");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);
    NumberFormat pf = NumberFormat.getPercentInstance();
    pf.setMinimumIntegerDigits(3);
    pf.setGroupingUsed(false);
    for (TaskInfo task : getTaskInfo()) {
      sb.append(nf.format(task.getTimeMillis())).append("  ");
      sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
      sb.append(task.getTaskName()).append("\n");
    }
  }
  return sb.toString();
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

protected String printStopWatch(StopWatch sw) {
    StringBuilder sb = new StringBuilder();
    StopWatch.TaskInfo[] tasks = sw.getTaskInfo();
    for (int i = 0; i < tasks.length; i++) {
      StopWatch.TaskInfo task = tasks[i];
      sb.append(task.getTaskName()).append(" ").append(task.getTimeMillis());
      if (i < tasks.length - 1) {
        sb.append(", ");
      }
    }
    return sb.toString();
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
  StringBuilder sb = new StringBuilder(shortSummary());
  sb.append('\n');
  if (!this.keepTaskList) {
    sb.append("No task info kept");
  }
  else {
    sb.append("-----------------------------------------\n");
    sb.append("ms     %     Task name\n");
    sb.append("-----------------------------------------\n");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);
    NumberFormat pf = NumberFormat.getPercentInstance();
    pf.setMinimumIntegerDigits(3);
    pf.setGroupingUsed(false);
    for (TaskInfo task : getTaskInfo()) {
      sb.append(nf.format(task.getTimeMillis())).append("  ");
      sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
      sb.append(task.getTaskName()).append("\n");
    }
  }
  return sb.toString();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Return an informative string describing all tasks performed
 * For custom reporting, call {@code getTaskInfo()} and use the task info directly.
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(shortSummary());
  if (this.keepTaskList) {
    for (TaskInfo task : getTaskInfo()) {
      sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
      long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
      sb.append(" = ").append(percent).append("%");
    }
  }
  else {
    sb.append("; no task info kept");
  }
  return sb.toString();
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Return an informative string describing all tasks performed
 * For custom reporting, call {@code getTaskInfo()} and use the task info directly.
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(shortSummary());
  if (this.keepTaskList) {
    for (TaskInfo task : getTaskInfo()) {
      sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
      long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
      sb.append(" = ").append(percent).append("%");
    }
  }
  else {
    sb.append("; no task info kept");
  }
  return sb.toString();
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
  StringBuilder sb = new StringBuilder(shortSummary());
  sb.append('\n');
  if (!this.keepTaskList) {
    sb.append("No task info kept");
  }
  else {
    sb.append("-----------------------------------------\n");
    sb.append("ms     %     Task name\n");
    sb.append("-----------------------------------------\n");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);
    NumberFormat pf = NumberFormat.getPercentInstance();
    pf.setMinimumIntegerDigits(3);
    pf.setGroupingUsed(false);
    for (TaskInfo task : getTaskInfo()) {
      sb.append(nf.format(task.getTimeMillis())).append("  ");
      sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
      sb.append(task.getTaskName()).append("\n");
    }
  }
  return sb.toString();
}

代码示例来源:origin: springframework/spring-core

/**
 * Return a string with a table describing all tasks performed.
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String prettyPrint() {
  StringBuffer sb = new StringBuffer(shortSummary());
  if (!this.keepTaskList) {
    sb.append("No task info kept");
  }
  else {
    TaskInfo[] tasks = getTaskInfo();
    sb.append("-----------------------------------------\n");
    sb.append("ms     %     Task name\n");
    sb.append("-----------------------------------------\n");
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);
    NumberFormat pf = NumberFormat.getPercentInstance();
    pf.setMinimumIntegerDigits(3);
    pf.setGroupingUsed(false);
    for (int i = 0; i < tasks.length; i++) {
      sb.append(nf.format(tasks[i].getTimeMillis()) + "  ");
      sb.append(pf.format(tasks[i].getTimeSeconds() / getTotalTimeSeconds()) + "  ");
      sb.append(tasks[i].getTaskName() + "\n");
    }
  }
  return sb.toString();
}

代码示例来源:origin: springframework/spring-core

/**
 * Return an informative string describing all tasks performed
 * For custom reporting, call getTaskInfo() and use the task info directly.
 */
public String toString() {
  StringBuffer sb = new StringBuffer(shortSummary());
  if (this.keepTaskList) {
    TaskInfo[] tasks = getTaskInfo();
    for (int i = 0; i < tasks.length; i++) {
      if (i > 0) {
        sb.append("; ");
      }
      sb.append("[" + tasks[i].getTaskName() + "] took " + tasks[i].getTimeMillis());
      long percent = Math.round((100.0 * tasks[i].getTimeSeconds()) / getTotalTimeSeconds());
      sb.append("=" + percent + "%");
    }
  }
  else {
    sb.append("Not keeping task info");
  }
  return sb.toString();
}

相关文章