Class StopWatch
java.lang.Object
com.sure.tool.lang.StopWatch
秒表计时器,参考 Hutool 的
StopWatch 设计。
基于 System.nanoTime() 累计耗时,支持分段累计与多次启停。
English: A monotonic stopwatch for measuring elapsed time in milliseconds and formatted strings.
- Since:
- 0.1.0
- Author:
- suretool
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
StopWatch
public StopWatch() -
StopWatch
-
-
Method Details
-
start
public void start()开始计时(已在计时中则忽略)。 -
stop
public void stop()停止计时并累计耗时(未在计时中则忽略)。 -
reset
public void reset()重置计时器。 -
isRunning
public boolean isRunning()是否正在计时。- Returns:
- 是否正在计时
-
getTotalTimeNanos
public long getTotalTimeNanos()累计耗时(纳秒)。- Returns:
- 累计耗时
-
getTotalTimeMillis
public long getTotalTimeMillis()累计耗时(毫秒)。- Returns:
- 累计耗时
-
getTotalTimeSeconds
public long getTotalTimeSeconds()累计耗时(秒)。- Returns:
- 累计耗时
-
getTime
-
prettyPrint
-
toString
-