Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this point. @return this Stopwatch instance @throws IllegalStateException if the stopwatch is already stopped.
()
| 147 | * @throws IllegalStateException if the stopwatch is already stopped. |
| 148 | */ |
| 149 | @CanIgnoreReturnValue |
| 150 | public Stopwatch stop() { |
| 151 | long tick = ticker.read(); |
| 152 | checkState(isRunning, "This stopwatch is already stopped."); |
| 153 | isRunning = false; |
| 154 | elapsedNanos += tick - startTick; |
| 155 | return this; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Sets the elapsed time for this stopwatch to zero, and places it in a stopped state. |
no test coverage detected