X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FExceptionWrapperBenchmark.cpp;h=16af2206bc03576970c0ae0b47c639a2de21f95c;hb=a857f83b2b25f42eeba1524ebca1bd2e74abc71a;hp=475fc897357165896454fbd73d79b4c0c716880e;hpb=275ca94d04e44f28cfa411668eb1c1dd8db90b80;p=folly.git diff --git a/folly/test/ExceptionWrapperBenchmark.cpp b/folly/test/ExceptionWrapperBenchmark.cpp index 475fc897..16af2206 100644 --- a/folly/test/ExceptionWrapperBenchmark.cpp +++ b/folly/test/ExceptionWrapperBenchmark.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 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. @@ -15,14 +15,14 @@ */ #include -#include #include #include -#include #include #include +#include #include +#include DEFINE_int32(num_threads, 32, "Number of threads to run concurrency " "benchmarks"); @@ -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(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(e); - assert(ew); + bool b = static_cast(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(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(e); - assert(ew); + bool b = static_cast(ew); + folly::doNotOptimizeAway(b); } }); } @@ -105,8 +109,7 @@ 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& e) { + } catch (std::runtime_error&) { } } } @@ -117,8 +120,7 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw, iters) { auto ew = folly::make_exception_wrapper(e); try { ew.throwException(); - assert(false); - } catch (std::runtime_error& e) { + } 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(e); - assert(ew.is_compatible_with()); + bool b = ew.is_compatible_with(); + folly::doNotOptimizeAway(b); } } @@ -146,8 +149,7 @@ 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& e) { + } catch (std::runtime_error&) { } } }); @@ -171,8 +173,7 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw_concurrent, iters) { auto ew = folly::make_exception_wrapper(e); try { ew.throwException(); - assert(false); - } catch (std::runtime_error& e) { + } 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(e); - assert(ew.is_compatible_with()); + bool b = ew.is_compatible_with(); + folly::doNotOptimizeAway(b); } }); }