21 #include <glog/logging.h> 27 using namespace folly;
31 template <
class BaseIter>
35 return std::find(begin, end,
true);
39 void runFFSTest(FFS fn) {
40 constexpr
size_t const maxblocks = 3;
41 constexpr
size_t const bpb = 8 *
sizeof(
uint64_t);
42 for (
size_t nblocks = 1; nblocks <= maxblocks; ++nblocks) {
44 size_t nbits = nblocks * bpb;
47 DCHECK_EQ(nbits, end -
begin);
52 for (
size_t firstSet = 0; firstSet <= nbits; ++firstSet) {
53 data.assign(nblocks, 0);
55 size_t b = firstSet - 1;
56 data[b / bpb] |= (1ULL << (b % bpb));
58 for (
size_t startBit = 0; startBit <= nbits; ++startBit) {
59 for (
size_t endBit = startBit; endBit <= nbits; ++endBit) {
60 auto p =
begin + startBit;
61 auto q =
begin + endBit;
64 if (firstSet < startBit + 1 || firstSet >= endBit + 1) {
65 DCHECK_EQ(endBit, p -
begin)
66 <<
" firstSet=" << firstSet <<
" startBit=" << startBit
67 <<
" endBit=" << endBit <<
" nblocks=" << nblocks;
69 DCHECK_EQ(firstSet - 1, p -
begin)
70 <<
" firstSet=" << firstSet <<
" startBit=" << startBit
71 <<
" endBit=" << endBit <<
" nblocks=" << nblocks;
79 void runSimpleFFSTest(
int iters) {
81 runFFSTest([](
auto first,
auto last) {
return simpleFFS(
first, last); });
85 void runRealFFSTest(
int iters) {
94 runSimpleFFSTest(iters);
97 runRealFFSTest(iters);
BitIterator< BaseIter > findFirstSet(BitIterator< BaseIter >, BitIterator< BaseIter >)
BitIterator< BaseIter > makeBitIterator(const BaseIter &iter)
auto begin(TestAdlIterable &instance)
—— Concurrent Priority Queue Implementation ——
void init(int *argc, char ***argv, bool removeFlags)
auto end(TestAdlIterable &instance)
constexpr auto data(C &c) -> decltype(c.data())
int main(int argc, char **argv)
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
constexpr detail::First first