Skip to content
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

Stopwatch Lap Duration #98

Merged
merged 1 commit into from
Apr 2, 2024
Merged

Conversation

rodnaph
Copy link
Contributor

@rodnaph rodnaph commented Mar 22, 2024

Return the lap duration when stopping the Stopwatch, which will be the duration since the last start.

If the stopwatch is not started, then the duration will be zero.

Use case - using a stopwatch to perform multiple duration timings, and then fetch the total elapsed time at the end (I can't see this is possible now, please direct me if I've just overlooked it though).

Note: CI failure does not seem related to my changes, as above though let me know if I missed something.

@gnutix
Copy link
Contributor

gnutix commented Mar 22, 2024

Sorry for the CI failure, it's fixed by #100.

@BenMorel
Copy link
Member

Hi, I like this idea, this feature is indeed missing!

What about adding a getLapTime() as well, to be able to get the duration since the last start without stopping?

By the way you can rebase now, this will fix the CS issue.

@rodnaph
Copy link
Contributor Author

rodnaph commented Mar 25, 2024

What about adding a getLapTime() as well, to be able to get the duration since the last start without stopping?

Thanks, I've added that method, let me know if there's anything I've missed.

src/Stopwatch.php Show resolved Hide resolved
tests/StopwatchTest.php Outdated Show resolved Hide resolved
tests/StopwatchTest.php Outdated Show resolved Hide resolved
tests/StopwatchTest.php Outdated Show resolved Hide resolved
src/Stopwatch.php Outdated Show resolved Hide resolved
@BenMorel
Copy link
Member

Apart from this, returning the duration in stop() looks good to me, @rodnaph. Let's fix the nitpicks and merge it!

@BenMorel BenMorel merged commit 303f57a into brick:master Apr 2, 2024
7 checks passed
@BenMorel
Copy link
Member

BenMorel commented Apr 2, 2024

Thank you, @rodnaph!

@BenMorel
Copy link
Member

BenMorel commented Apr 2, 2024

Released as 0.6.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants