Commit 147a597e authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Avoid gtest expectations in UnboundedQueue benchmark

Summary: [Folly] Avoid gtest expectations in `UnboundedQueue` benchmark; prefer `DCHECK` so assumptions may be validated without `NDEBUG` but so measurements may be taken with `NDEBUG`.

Reviewed By: magedm

Differential Revision: D13192005

fbshipit-source-id: 133cf0b8ed0e924e5c9ad3e7b85035fa061ccc40
parent 49838bbf
...@@ -268,10 +268,9 @@ void enq_deq_test(const int nprod, const int ncons) { ...@@ -268,10 +268,9 @@ void enq_deq_test(const int nprod, const int ncons) {
}; };
auto endfn = [&] { auto endfn = [&] {
uint64_t expected = ops; uint64_t expected = (ops) * (ops - 1) / 2;
expected *= ops - 1; uint64_t actual = sum.load();
expected /= 2; ASSERT_EQ(expected, actual);
ASSERT_EQ(sum.load(), expected);
}; };
run_once(nprod, ncons, prod, cons, endfn); run_once(nprod, ncons, prod, cons, endfn);
} }
...@@ -368,7 +367,7 @@ uint64_t bench(const int nprod, const int ncons, const std::string& name) { ...@@ -368,7 +367,7 @@ uint64_t bench(const int nprod, const int ncons, const std::string& name) {
/* keep trying */; /* keep trying */;
} }
} else { } else {
ASSERT_TRUE(Op == 2 || Op == 5); DCHECK(Op == 2 || Op == 5);
q.dequeue(v); q.dequeue(v);
} }
if (nprod == 1 && ncons == 1) { if (nprod == 1 && ncons == 1) {
...@@ -379,10 +378,9 @@ uint64_t bench(const int nprod, const int ncons, const std::string& name) { ...@@ -379,10 +378,9 @@ uint64_t bench(const int nprod, const int ncons, const std::string& name) {
sum.fetch_add(mysum); sum.fetch_add(mysum);
}; };
auto endfn = [&] { auto endfn = [&] {
uint64_t expected = ops; uint64_t expected = (ops) * (ops - 1) / 2;
expected *= ops - 1; uint64_t actual = sum.load();
expected /= 2; DCHECK_EQ(expected, actual);
ASSERT_EQ(sum.load(), expected);
}; };
return run_once(nprod, ncons, prod, cons, endfn); return run_once(nprod, ncons, prod, cons, endfn);
}; };
......
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