X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Ftest%2FExceptionWrapperBenchmark.cpp;h=dc52f5ce3e7510c3ce93f9b8add581b445550f97;hp=6d6fc786e62abd89b9640dc92680508e4d1534b5;hb=337e3b8a157210eea33c88361b5e4c45a5efc462;hpb=908783ccbb57ab797c88806119f9294e85e6089a diff --git a/folly/test/ExceptionWrapperBenchmark.cpp b/folly/test/ExceptionWrapperBenchmark.cpp index 6d6fc786..dc52f5ce 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,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&) { } } @@ -116,8 +119,7 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw, iters) { for (size_t i = 0; i < iters; ++i) { auto ew = folly::make_exception_wrapper(e); try { - ew.throwException(); - assert(false); + ew.throw_exception(); } 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,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&) { } } @@ -170,8 +172,7 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw_concurrent, iters) { for (size_t i = 0; i < iters; ++i) { auto ew = folly::make_exception_wrapper(e); try { - ew.throwException(); - assert(false); + ew.throw_exception(); } 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); } }); }