/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
#include <folly/ExceptionWrapper.h>
-#include <gflags/gflags.h>
#include <atomic>
#include <exception>
-#include <vector>
#include <stdexcept>
#include <thread>
+#include <vector>
#include <folly/Benchmark.h>
+#include <folly/portability/GFlags.h>
DEFINE_int32(num_threads, 32, "Number of threads to run concurrency "
"benchmarks");
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);
}
}
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);
}
}
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);
}
});
}
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);
}
});
}
auto ep = std::make_exception_ptr(e);
try {
std::rethrow_exception(ep);
- assert(false);
- } catch (std::runtime_error& e) {
+ } catch (std::runtime_error&) {
}
}
}
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
try {
- ew.throwException();
- assert(false);
- } catch (std::runtime_error& e) {
+ ew.throw_exception();
+ } catch (std::runtime_error&) {
}
}
}
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);
}
}
auto ep = std::make_exception_ptr(e);
try {
std::rethrow_exception(ep);
- assert(false);
- } catch (std::runtime_error& e) {
+ } catch (std::runtime_error&) {
}
}
});
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
try {
- ew.throwException();
- assert(false);
- } catch (std::runtime_error& e) {
+ ew.throw_exception();
+ } catch (std::runtime_error&) {
}
}
});
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);
}
});
}