类 TimerContext

java.lang.Object
com.alibaba.nacos.core.utils.TimerContext

public class TimerContext extends Object
Simple task time calculation,Currently only the task time statistics task that supports synchronizing code blocks is supported.
作者:
liaochuntao
  • 构造器详细资料

    • TimerContext

      public TimerContext()
  • 方法详细资料

    • start

      public static void start(String name)
      Record context start time.
      参数:
      name - context name
    • end

      public static void end(String name, org.slf4j.Logger logger)
    • end

      public static void end(String name, org.slf4j.Logger logger, String level)
      End the task and print based on the log level.
      参数:
      name - context name
      logger - logger
      level - logger level
    • run

      public static void run(Runnable job, String name, org.slf4j.Logger logger)
      Execution with time-consuming calculations for Runnable.
      参数:
      job - runnable
      name - job name
      logger - logger
    • run

      public static <V> V run(Supplier<V> job, String name, org.slf4j.Logger logger)
      Execution with time-consuming calculations for Supplier.
      参数:
      job - Supplier
      name - job name
      logger - logger
    • run

      public static <T,​ R> R run(Function<T,​R> job, T args, String name, org.slf4j.Logger logger)
      Execution with time-consuming calculations for Function.
      参数:
      job - Function
      args - args
      name - job name
      logger - logger
    • run

      public static <T> void run(Consumer<T> job, T args, String name, org.slf4j.Logger logger)
      Execution with time-consuming calculations for Consumer.
      参数:
      job - Consumer
      args - args
      name - job name
      logger - logger