X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2Ffunction_benchmark%2Fmain.cpp;h=7b12aba339b5d88f1f29256af2b96c4666dee8ab;hb=717229ecf385ee10a91d6c2af859e8550df84531;hp=20d5b7ddff4a0f9fa89b6b4cdca246f17a3e1848;hpb=ed8c80a0e0988e4ce687f51ca832a00e4a6b7930;p=folly.git diff --git a/folly/test/function_benchmark/main.cpp b/folly/test/function_benchmark/main.cpp index 20d5b7dd..7b12aba3 100644 --- a/folly/test/function_benchmark/main.cpp +++ b/folly/test/function_benchmark/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2017 Facebook, Inc. + * Copyright 2011-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include #include -using folly::ScopeGuard; using folly::makeGuard; // Declare the bm_max_iters flag from folly/Benchmark.cpp @@ -158,7 +157,8 @@ BENCHMARK(std_bind_direct_invoke, iters) { BENCHMARK(scope_guard_std_function, iters) { std::function fn(doNothing); for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard(fn); + auto g = makeGuard(fn); + (void)g; } } @@ -166,7 +166,8 @@ BENCHMARK(scope_guard_std_function, iters) { // but create the ScopeGuard with an rvalue to a std::function BENCHMARK(scope_guard_std_function_rvalue, iters) { for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard(std::function(doNothing)); + auto g = makeGuard(std::function(doNothing)); + (void)g; } } @@ -174,28 +175,32 @@ BENCHMARK(scope_guard_std_function_rvalue, iters) { // but create the ScopeGuard with an rvalue to a folly::Function BENCHMARK(scope_guard_Function_rvalue, iters) { for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard(folly::Function(doNothing)); + auto g = makeGuard(folly::Function(doNothing)); + (void)g; } } // Using ScopeGuard to invoke a function pointer BENCHMARK(scope_guard_fn_ptr, iters) { for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard(doNothing); + auto g = makeGuard(doNothing); + (void)g; } } // Using ScopeGuard to invoke a lambda that does nothing BENCHMARK(scope_guard_lambda_noop, iters) { for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard([] {}); + auto g = makeGuard([] {}); + (void)g; } } // Using ScopeGuard to invoke a lambda that invokes a function BENCHMARK(scope_guard_lambda_function, iters) { for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard([] { doNothing(); }); + auto g = makeGuard([] { doNothing(); }); + (void)g; } } @@ -203,7 +208,7 @@ BENCHMARK(scope_guard_lambda_function, iters) { BENCHMARK(scope_guard_lambda_local_var, iters) { uint32_t count = 0; for (size_t n = 0; n < iters; ++n) { - ScopeGuard g = makeGuard([&] { + auto g = makeGuard([&] { // Increment count if n is odd. Without this conditional check // (i.e., if we just increment count each time through the loop), // gcc is smart enough to optimize the entire loop away, and just set @@ -212,6 +217,7 @@ BENCHMARK(scope_guard_lambda_local_var, iters) { ++count; } }); + (void)g; } // Check that the value of count is what we expect.