Commit 7ea05dfb authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

don't use assert in benchmarks. it gets stripped out in release mode.

Summary: Critical tests in benchmarks should not be in asserts since they will be stripped out in release mode, which is the only mode interesting for benchmarks.

Reviewed By: yfeldblum

Differential Revision: D4384411

fbshipit-source-id: 5237ab48f99ddcd2bce7a159fcf82900303efec2
parent 9b7138e4
......@@ -36,7 +36,8 @@ BENCHMARK(exception_ptr_create_and_test, iters) {
std::runtime_error e("payload");
for (size_t i = 0; i < iters; ++i) {
auto ep = std::make_exception_ptr(e);
assert(ep);
bool b = static_cast<bool>(ep);
folly::doNotOptimizeAway(b);
}
}
......@@ -44,7 +45,8 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_test, iters) {
std::runtime_error e("payload");
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
assert(ew);
bool b = static_cast<bool>(ew);
folly::doNotOptimizeAway(b);
}
}
......@@ -60,7 +62,8 @@ BENCHMARK(exception_ptr_create_and_test_concurrent, iters) {
std::runtime_error e("payload");
for (size_t i = 0; i < iters; ++i) {
auto ep = std::make_exception_ptr(e);
assert(ep);
bool b = static_cast<bool>(ep);
folly::doNotOptimizeAway(b);
}
});
}
......@@ -81,7 +84,8 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_test_concurrent, iters) {
std::runtime_error e("payload");
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
assert(ew);
bool b = static_cast<bool>(ew);
folly::doNotOptimizeAway(b);
}
});
}
......@@ -105,7 +109,6 @@ BENCHMARK(exception_ptr_create_and_throw, iters) {
auto ep = std::make_exception_ptr(e);
try {
std::rethrow_exception(ep);
assert(false);
} catch (std::runtime_error&) {
}
}
......@@ -117,7 +120,6 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw, iters) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
try {
ew.throwException();
assert(false);
} catch (std::runtime_error&) {
}
}
......@@ -127,7 +129,8 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_cast, iters) {
std::runtime_error e("payload");
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
assert(ew.is_compatible_with<std::runtime_error>());
bool b = ew.is_compatible_with<std::runtime_error>();
folly::doNotOptimizeAway(b);
}
}
......@@ -146,7 +149,6 @@ BENCHMARK(exception_ptr_create_and_throw_concurrent, iters) {
auto ep = std::make_exception_ptr(e);
try {
std::rethrow_exception(ep);
assert(false);
} catch (std::runtime_error&) {
}
}
......@@ -171,7 +173,6 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw_concurrent, iters) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
try {
ew.throwException();
assert(false);
} catch (std::runtime_error&) {
}
}
......@@ -194,7 +195,8 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_cast_concurrent, iters) {
std::runtime_error e("payload");
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
assert(ew.is_compatible_with<std::runtime_error>());
bool b = ew.is_compatible_with<std::runtime_error>();
folly::doNotOptimizeAway(b);
}
});
}
......
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