-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement StopWatch lap #709
base: master
Are you sure you want to change the base?
Conversation
Example: StopWatch watch = StopWatch.createStarted(); sleep(30ms) watch.lap() // returns 30 sleep(10ms) watch.lap() // returns 10
BTW, split has a bug: if stop watch is suspended and resumed, startTimeNanos is moved forward but stopTimeNanos not. For example:
IMHO split is overengineering. Instead of BTW2, I suggest also drop |
I think you need to explain in the class Javadoc how lap works, especially in contrast to split. What does it mean to lap a stopped watch, and such edge cases, and error states. The whole class makes me wonder if we need to redo it in terms of java.time.Duration. |
@garydgregory, explanation how The problem is that current First problem is state diagram (life-cycle). As a software developer, I want stop watch to measure how long runs some piece of code. I want get time spent between start and stop point, without learning stopwatch states. I'm afraid that current What do you think about creating new class,
?
|
Example:
StopWatch watch = StopWatch.createStarted();
sleep(30ms)
watch.lap() // returns 30
sleep(10ms)
watch.lap() // returns 10