Commit 549f235f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

tweak rcu benchmarks

Summary:
Add a benchmark for `rcu_retire`. Remove perf code from the rcu tests.

As a motivating side-effect, removes faulty calls to `printf` which fail to compile across platforms, including mac.

Differential Revision: D27902852

fbshipit-source-id: 1698a0fd8ca3731f0b794cb1c2cb08c4bfb5d714
parent cd58205e
......@@ -19,23 +19,28 @@
using namespace folly;
void runTest(int iters) {
BENCHMARK(RcuReader, iters) {
BenchmarkSuspender susp;
{ rcu_reader g; }
susp.dismiss();
// run the test loop
for (int i = 0; i < iters; i++) {
while (iters--) {
rcu_reader g;
}
}
BENCHMARK_DRAW_LINE();
BENCHMARK(RcuReader, iters) {
runTest(iters);
BENCHMARK(RcuRetire, iters) {
BenchmarkSuspender susp;
rcu_retire<int>(nullptr, [](int*) {});
susp.dismiss();
while (iters--) {
rcu_retire<int>(nullptr, [](int*) {});
}
}
BENCHMARK_DRAW_LINE();
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
......
......@@ -53,32 +53,6 @@ TEST(RcuTest, Guard) {
EXPECT_TRUE(del);
}
TEST(RcuTest, Perf) {
long i = FLAGS_iters;
auto start = std::chrono::steady_clock::now();
while (i-- > 0) {
rcu_reader g;
}
auto diff = std::chrono::steady_clock::now() - start;
printf(
"Total time %li ns \n",
std::chrono::duration_cast<std::chrono::nanoseconds>(diff).count() /
FLAGS_iters);
}
TEST(RcuTest, ResetPerf) {
long i = FLAGS_iters;
auto start = std::chrono::steady_clock::now();
while (i-- > 0) {
rcu_retire<int>(nullptr, [](int*) {});
}
auto diff = std::chrono::steady_clock::now() - start;
printf(
"Total time %li ns \n",
std::chrono::duration_cast<std::chrono::nanoseconds>(diff).count() /
FLAGS_iters);
}
TEST(RcuTest, SlowReader) {
std::thread t;
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment