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

Benchmarking a function returning borrowed data #285

Open
Licenser opened this issue Apr 9, 2019 · 3 comments
Open

Benchmarking a function returning borrowed data #285

Licenser opened this issue Apr 9, 2019 · 3 comments
Labels

Comments

@Licenser
Copy link

@Licenser Licenser commented Apr 9, 2019

Hi,
I was wondering how to benchmark a function that returns borrowed data within including the drop in he measures?

@bheisler

This comment has been minimized.

Copy link
Owner

@bheisler bheisler commented Apr 10, 2019

Hey, thanks for trying Criterion.rs.

You might be looking for iter_batched_ref. If that's not it, could you explain your problem in more detail?

@Licenser

This comment has been minimized.

Copy link
Author

@Licenser Licenser commented Apr 10, 2019

Thanks for the quick reply :) I tried _ref but I’m not getting it to work sadly. I think it is about the lifetime of the input not he output in _ref? But I could be wrong - lifetimes are still my arch nemesis in rust -.- what I’m trying to do is get rid of this semicolon so that the drop happens outside the benchmark loop.

@bheisler

This comment has been minimized.

Copy link
Owner

@bheisler bheisler commented Apr 12, 2019

Ah, I see what you mean now.

Unfortunately, I don't think that's currently possible. Worse, I'm not even certain that it's possible for Criterion.rs to support that. It ought to be safe - the returned reference should never outlive the input - but I have no idea how to convince rustc of that.

Sorry I can't be more helpful. I'll leave this open in case somebody out there knows some lifetime trickery I don't know. I've put up a minimal test case on the Playground in case anyone wants to take a go.

@bheisler bheisler added the Enhancement label Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.