Benchmarking a function returning borrowed data
Hi, I was wondering how to benchmark a function that returns borrowed data within including the drop in he measures?
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?
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.
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.