33 uint8_t slowDefaultNumLowerBits(
size_t upperBound,
size_t size) {
34 if (size == 0 || upperBound < size) {
43 TEST(EliasFanoCoding, defaultNumLowerBits) {
46 static constexpr
size_t kNumIterations = 2500;
47 auto compare = [](
size_t upperBound,
size_t size) {
50 int(slowDefaultNumLowerBits(upperBound, size)),
51 int(Encoder::defaultNumLowerBits(upperBound, size)))
52 << upperBound <<
" " <<
size;
54 auto batch = [&compare](
size_t initialUpperBound) {
55 for (
size_t upperBound = initialUpperBound,
i = 0;
i < kNumIterations;
58 for (
size_t size = upperBound, j = 0; j < kNumIterations; ++j, --
size) {
59 compare(upperBound, size);
62 for (
size_t size = upperBound; size > 1 + upperBound / kNumIterations;
63 size -= 1 + upperBound / kNumIterations) {
64 compare(upperBound, size);
67 for (
size_t size = 0; size < kNumIterations; ++
size) {
68 compare(upperBound, size);
73 batch(kNumIterations + 1312213123);
74 batch(kNumIterations);
77 std::uniform_int_distribution<size_t> distribution;
78 for (
size_t i = 0;
i < kNumIterations; ++
i) {
79 const auto a = distribution(gen);
80 const auto b = distribution(gen);
90 testEmpty<Reader, Encoder>();
93 template <
size_t kSkipQuantum,
size_t kForwardQuantum,
class SizeType>
103 testAll<Reader, Encoder>({0});
114 doTestAll<0, 0, uint32_t>();
115 doTestAll<0, 0, size_t>();
119 doTestAll<128, 0, uint32_t>();
120 doTestAll<128, 0, size_t>();
124 doTestAll<0, 128, uint32_t>();
125 doTestAll<0, 128, size_t>();
129 doTestAll<128, 128, uint32_t>();
130 doTestAll<128, 128, size_t>();
136 constexpr
uint32_t kLargeValue = 127;
141 std::vector<uint32_t>
data = {0, kLargeValue};
143 data.push_back(data.back() + 1);
161 std::vector<uint32_t>
data;
162 std::vector<size_t>
order;
177 order.resize(data.size());
178 std::iota(order.begin(), order.end(), size_t());
179 std::shuffle(order.begin(), order.end(), gen);
184 std::uniform_int_distribution<size_t> distribution;
185 for (
size_t i = 0;
i < 10000; ++
i) {
186 const auto a = distribution(gen);
187 const auto b = distribution(gen);
200 bmNext<EliasFanoReader<bm::Encoder, decltype(instructions)>>(
207 bmSkip<EliasFanoReader<bm::Encoder, decltype(instructions)>>(
223 bmJump<EliasFanoReader<bm::Encoder, decltype(instructions)>>(
232 bmSkipTo<EliasFanoReader<bm::Encoder, decltype(instructions)>>(
248 bmJumpTo<EliasFanoReader<bm::Encoder, decltype(instructions)>>(
297 ============================================================================
299 ============================================================================
308 Jump_ForwardQ128 20.27ns 49.33M
309 ----------------------------------------------------------------------------
317 JumpTo_SkipQ128 44.79ns 22.33M
318 ----------------------------------------------------------------------------
319 Encode_10 120.33ns 8.31M
321 ----------------------------------------------------------------------------
322 defaultNumLowerBits 3.69ns 270.74M
323 slowDefaultNumLowerBits 10.90ns 91.73M
324 ============================================================================
330 gflags::ParseCommandLineFlags(&argc, &argv,
true);
333 if (ret == 0 && FLAGS_benchmark) {
std::vector< uint32_t > data
auto dispatchInstructions(F &&f) -> decltype(f(std::declval< instructions::Default >()))
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
size_t SkipTo_SkipQ128(size_t iters, size_t logAvgSkip)
BitVectorEncoder< uint32_t, uint32_t, 128, 128 > Encoder
#define ASSERT_EQ(val1, val2)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
std::vector< uint32_t > encodeSmallData
#define EXPECT_EQ(val1, val2)
std::vector< uint32_t > encodeLargeData
auto begin(TestAdlIterable &instance)
int main(int argc, char **argv)
detail::Batch batch(size_t batchSize)
std::vector< uint32_t > generateRandomList(size_t n, uint32_t maxId, URNG &&g)
—— Concurrent Priority Queue Implementation ——
size_t Skip_ForwardQ128(size_t iters, size_t logAvgSkip)
void init(int *argc, char ***argv, bool removeFlags)
static MutableCompressedList encode(RandomAccessIterator begin, RandomAccessIterator end)
constexpr auto size(C const &c) -> decltype(c.size())
std::vector< size_t > order
auto end(TestAdlIterable &instance)
std::vector< uint32_t > generateSeqList(uint32_t minId, uint32_t maxId, uint32_t step=1)
constexpr auto data(C &c) -> decltype(c.data())
Encoder::MutableCompressedList list
constexpr unsigned int findLastSet(T const v)
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
auto free() -> decltype(::free(T(nullptr)))
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
std::vector< std::pair< size_t, size_t > > numLowerBitsInput
#define ASSERT_TRUE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
#define BENCHMARK_NAMED_PARAM_MULTI(name, param_name,...)
std::chrono::nanoseconds time()
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type