Package com.alibaba.nacos.sys.utils
Class TimerContext
java.lang.Object
com.alibaba.nacos.sys.utils.TimerContext
Simple task time calculation,Currently only the task time statistics task that supports synchronizing code blocks is
supported.
- Author:
- liaochuntao
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidEnd the task and print based on the log level.static voidExecution with time-consuming calculations forRunnable.static <T> voidExecution with time-consuming calculations forConsumer.static <T,R> R Execution with time-consuming calculations forFunction.static <V> VExecution with time-consuming calculations forSupplier.static voidRecord context start time.
-
Constructor Details
-
TimerContext
public TimerContext()
-
-
Method Details
-
start
Record context start time.- Parameters:
name- context name
-
end
-
end
End the task and print based on the log level.- Parameters:
name- context namelogger- loggerlevel- logger level
-
run
Execution with time-consuming calculations forRunnable.- Parameters:
job- runnablename- job namelogger- logger
-
run
Execution with time-consuming calculations forSupplier.- Parameters:
job- Suppliername- job namelogger- logger
-
run
Execution with time-consuming calculations forFunction.- Parameters:
job- Functionargs- argsname- job namelogger- logger
-
run
Execution with time-consuming calculations forConsumer.- Parameters:
job- Consumerargs- argsname- job namelogger- logger
-