Commit 3619b401 authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

Benchmark a realistic common use

Summary:
We didn't previously benchmark the performance of `get()`, which was a strange
omission.

Reviewed By: akrieger

Differential Revision: D5863567

fbshipit-source-id: 468b249da9120fcb84f3303ac5e2157761b6369d
parent 94b8816b
......@@ -290,6 +290,44 @@ BENCHMARK_RELATIVE(throwWrappedAndCatchWrappedContended) {
contend(throwWrappedAndCatchWrappedImpl);
}
BENCHMARK_DRAW_LINE();
namespace {
struct Bulky {
explicit Bulky(std::string message) : message_(message) {}
std::string message() & {
return message_;
}
std::string&& message() && {
return std::move(message_);
}
private:
std::string message_;
std::array<int, 1024> ints_;
};
} // anonymous namespace
BENCHMARK(lvalue_get) {
BenchmarkSuspender suspender;
Optional<Future<Bulky>> future;
future = makeFuture(Bulky("Hello"));
suspender.dismissing([&] {
std::string message = future.value().get().message();
doNotOptimizeAway(message);
});
}
BENCHMARK_RELATIVE(rvalue_get) {
BenchmarkSuspender suspender;
Optional<Future<Bulky>> future;
future = makeFuture(Bulky("Hello"));
suspender.dismissing([&] {
std::string message = std::move(future.value()).get().message();
doNotOptimizeAway(message);
});
}
InlineExecutor exe;
template <class T>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment