X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FExceptionWrapperBenchmark.cpp;h=16af2206bc03576970c0ae0b47c639a2de21f95c;hb=dd71ee635cd1555e41398cbe48d6eb83ece8b88d;hp=fbd72820c4cdce9010657462c114fb673bcd477d;hpb=4598dd7067fb84d53913acaf80d0df585ba4d0f7;p=folly.git diff --git a/folly/test/ExceptionWrapperBenchmark.cpp b/folly/test/ExceptionWrapperBenchmark.cpp index fbd72820..16af2206 100644 --- a/folly/test/ExceptionWrapperBenchmark.cpp +++ b/folly/test/ExceptionWrapperBenchmark.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -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); } }); }