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

Consider a Stopwatch API that accept a lambda and returns a Duration #3535

Open
kluever opened this issue Jul 24, 2019 · 4 comments
Open

Consider a Stopwatch API that accept a lambda and returns a Duration #3535

kluever opened this issue Jul 24, 2019 · 4 comments

Comments

@kluever
Copy link
Member

kluever commented Jul 24, 2019

E.g.,
Duration elapsed = Stopwatch.measure(() -> <code goes here>);

@kevinb9n
Copy link
Contributor

Supporting void lambdas sound great.

@ogregoire
Copy link

ogregoire commented Jul 24, 2019

This seems to be very limiting since the result of non-void lambdas can't be used.

Maybe a TimedResult<T> can be returned, so that both the duration and the actual result can be retrieved?

@netdpb
Copy link
Member

netdpb commented Jul 31, 2019

Relevant to discussion in #3528.

@kluever
Copy link
Member Author

kluever commented Jul 31, 2019

@FuncGuy Thanks for getting this started.

Unfortunately there's a bit more work that needs to happen before we can start reviewing this PR. See the steps here, specifically:

Note: We know it's tempting to submit code before the feature is accepted, but this is not always a good use of your time. First, the community has to discuss whether the feature is a good fit for Guava, then the API gets hammered out, and then code happens. Sending in code won't help a feature request get accepted.

We have a fairly rigorous API review process that someone (most likely I) will have to follow before we touch any code. I'll try to prioritize that sometime in the next few weeks.

Thanks again!

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

No branches or pull requests

4 participants