/** 秒表汇总。 */
 public static void summarize(AbstractStopWatchSummary stopWatchSummary) {
   StopWatch stopWatch = StopWatchContext.get();
   LOGGER.trace("Print [{}] Stopwatch Info", stopWatch.getId());
   if (stopWatchSummary.getLogger() == null) {
     stopWatchSummary.setLogger(LOGGER);
   }
   stopWatchSummary.summarize(stopWatch);
 }
  @Override
  public void summarize(StopWatch stopWatch, Logger logger) {
    if (logger.isTraceEnabled()) {
      logger.trace(
          "StopWatch '{}': start timestamp(ns): {}, stop timestamp(ns): {}, running time = {} ({} ns) ({} us) ({} ms), task count: {}",
          new Object[] {
            stopWatch.getId(),
            stopWatch.getStartTime(),
            stopWatch.getStopTime(),
            DurationFormatUtils.formatDuration(
                stopWatch.getTotalTime() / DateUtils.NANOS_PER_MILLIS,
                StopWatchSummary.DATE_FORMAT),
            stopWatch.getTotalTime(),
            stopWatch.getTotalTime() / DateUtils.NANOS_PER_MICROS,
            stopWatch.getTotalTime() / DateUtils.NANOS_PER_MILLIS,
            stopWatch.getTaskCount()
          });
      if (stopWatch.getTaskCount() == 0) {
        logger.trace("No task info kept");
      } else {

        TaskInfo[] taskInfos = stopWatch.getTaskInfo();
        if (sort) {
          Arrays.sort(
              taskInfos,
              new Comparator<TaskInfo>() {

                @Override
                public int compare(TaskInfo o1, TaskInfo o2) {
                  return new ComparableComparator().compare(o2.getTotalTime(), o1.getTotalTime());
                }
              });
        }
        for (TaskInfo task : taskInfos) {
          logger.trace(
              "\tTask Name '{}': start timestamp(ns): {}, stop timestamp(ns): {}, running time: {} ({} ns) ({} us) ({} ms) ({})",
              new Object[] {
                task.getTaskName(),
                task.getStartTime(),
                task.getStopTime(),
                DurationFormatUtils.formatDuration(
                    task.getTotalTime() / DateUtils.NANOS_PER_MILLIS, StopWatchSummary.DATE_FORMAT),
                task.getTotalTime(),
                task.getTotalTime() / DateUtils.NANOS_PER_MICROS,
                task.getTotalTime() / DateUtils.NANOS_PER_MILLIS,
                pf.format(task.getTotalTime() / (double) stopWatch.getTotalTime())
              });
        }
      }
    }
  }
 /** 标记任务。 */
 public static void mark(String taskName) {
   StopWatch stopWatch = StopWatchContext.get();
   LOGGER.trace("Add [{}] Task", taskName);
   stopWatch.mark(taskName);
 }
 /** 恢复秒表计时。 */
 public static void resume() {
   StopWatch stopWatch = StopWatchContext.get();
   LOGGER.trace("Resume [{}] Stopwatch", stopWatch.getId());
   stopWatch.resume();
 }
 /** 暂停秒表计时。 */
 public static void suspend() {
   StopWatch stopWatch = StopWatchContext.get();
   LOGGER.trace("Suspend [{}] Stopwatch", stopWatch.getId());
   stopWatch.suspend();
 }
 /** 开始秒表计时。 */
 public static void start(String stopWatchId) {
   StopWatch stopWatch = new StopWatch(stopWatchId);
   StopWatchContext.set(stopWatch);
   LOGGER.trace("Begin [{}] Stopwatch", stopWatch.getId());
   stopWatch.start();
 }