proxygen
BitVectorCodingTest.cpp File Reference
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <folly/Benchmark.h>
#include <folly/experimental/BitVectorCoding.h>
#include <folly/experimental/Select64.h>
#include <folly/experimental/test/CodingTestUtils.h>
#include <folly/init/Init.h>

Go to the source code of this file.

Classes

class  BitVectorCodingTest
 

Namespaces

 bm
 

Typedefs

typedef BitVectorEncoder< uint32_t, uint32_t, 128, 128 > bm::Encoder
 

Functions

 TEST_F (BitVectorCodingTest, Empty)
 
 TEST_F (BitVectorCodingTest, Simple)
 
 TEST_F (BitVectorCodingTest, SkipPointers)
 
 TEST_F (BitVectorCodingTest, ForwardPointers)
 
 TEST_F (BitVectorCodingTest, SkipForwardPointers)
 
void bm::init ()
 
void bm::free ()
 
 BENCHMARK (Next, iters)
 
size_t Skip_ForwardQ128 (size_t iters, size_t logAvgSkip)
 
 BENCHMARK (Jump_ForwardQ128, iters)
 
 BENCHMARK_DRAW_LINE ()
 
size_t SkipTo_SkipQ128 (size_t iters, size_t logAvgSkip)
 
 BENCHMARK (JumpTo_SkipQ128, iters)
 
 BENCHMARK (Encode_10)
 
 BENCHMARK (Encode)
 
int main (int argc, char **argv)
 

Variables

std::vector< uint32_tbm::data
 
std::vector< size_t > bm::order
 
std::vector< uint32_tbm::encodeSmallData
 
std::vector< uint32_tbm::encodeLargeData
 
Encoder::MutableCompressedList bm::list
 

Function Documentation

BENCHMARK ( Next  ,
iters   
)

Definition at line 100 of file BitVectorCodingTest.cpp.

References bm::data, folly::compression::dispatchInstructions(), and bm::list.

100  {
101  dispatchInstructions([&](auto instructions) {
102  bmNext<BitVectorReader<bm::Encoder, decltype(instructions)>>(
103  bm::list, bm::data, iters);
104  });
105 }
std::vector< uint32_t > data
auto dispatchInstructions(F &&f) -> decltype(f(std::declval< instructions::Default >()))
Encoder::MutableCompressedList list
BENCHMARK ( Jump_ForwardQ128  ,
iters   
)

Definition at line 123 of file BitVectorCodingTest.cpp.

References folly::BENCHMARK_DRAW_LINE(), bm::data, folly::compression::dispatchInstructions(), bm::list, and bm::order.

123  {
124  dispatchInstructions([&](auto instructions) {
125  bmJump<BitVectorReader<bm::Encoder, decltype(instructions)>>(
126  bm::list, bm::data, bm::order, iters);
127  });
128 }
std::vector< uint32_t > data
auto dispatchInstructions(F &&f) -> decltype(f(std::declval< instructions::Default >()))
std::vector< size_t > order
Encoder::MutableCompressedList list
BENCHMARK ( JumpTo_SkipQ128  ,
iters   
)

Definition at line 148 of file BitVectorCodingTest.cpp.

References folly::BENCHMARK_DRAW_LINE(), bm::data, folly::compression::dispatchInstructions(), bm::list, and bm::order.

148  {
149  dispatchInstructions([&](auto instructions) {
150  bmJumpTo<BitVectorReader<bm::Encoder, decltype(instructions)>>(
151  bm::list, bm::data, bm::order, iters);
152  });
153 }
std::vector< uint32_t > data
auto dispatchInstructions(F &&f) -> decltype(f(std::declval< instructions::Default >()))
std::vector< size_t > order
Encoder::MutableCompressedList list
BENCHMARK ( Encode_10  )

Definition at line 157 of file BitVectorCodingTest.cpp.

References folly::test::begin(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::encode(), bm::encodeSmallData, folly::test::end(), folly::compression::BitVectorCompressedListBase< Pointer >::free(), and bm::list.

157  {
158  auto list = bm::Encoder::encode(
160  list.free();
161 }
std::vector< uint32_t > encodeSmallData
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
static MutableCompressedList encode(RandomAccessIterator begin, RandomAccessIterator end)
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
Encoder::MutableCompressedList list
auto free() -> decltype(::free(T(nullptr)))
BENCHMARK ( Encode  )

Definition at line 163 of file BitVectorCodingTest.cpp.

References folly::test::begin(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::encode(), bm::encodeLargeData, folly::test::end(), folly::compression::BitVectorCompressedListBase< Pointer >::free(), bm::list, s, Skip_ForwardQ128(), SkipTo_SkipQ128(), and folly::detail::distributed_mutex::time().

163  {
164  auto list = bm::Encoder::encode(
166  list.free();
167 }
std::vector< uint32_t > encodeLargeData
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
static MutableCompressedList encode(RandomAccessIterator begin, RandomAccessIterator end)
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
Encoder::MutableCompressedList list
auto free() -> decltype(::free(T(nullptr)))
BENCHMARK_DRAW_LINE ( )
int main ( int  argc,
char **  argv 
)

Definition at line 200 of file BitVectorCodingTest.cpp.

References bm::free(), folly::init(), bm::init(), testing::InitGoogleTest(), RUN_ALL_TESTS(), and folly::runBenchmarks().

200  {
202  folly::init(&argc, &argv);
203  gflags::ParseCommandLineFlags(&argc, &argv, true);
204 
205  auto ret = RUN_ALL_TESTS();
206  if (ret == 0 && FLAGS_benchmark) {
207  bm::init();
209  bm::free();
210  }
211 
212  return ret;
213 }
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: gtest.h:2232
void runBenchmarks()
Definition: Benchmark.cpp:456
void init()
void init(int *argc, char ***argv, bool removeFlags)
Definition: Init.cpp:34
char ** argv
void free()
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: gtest.cc:5370
size_t Skip_ForwardQ128 ( size_t  iters,
size_t  logAvgSkip 
)

Definition at line 107 of file BitVectorCodingTest.cpp.

References BENCHMARK_NAMED_PARAM_MULTI, bm::data, folly::compression::dispatchInstructions(), and bm::list.

Referenced by BENCHMARK().

107  {
108  dispatchInstructions([&](auto instructions) {
109  bmSkip<BitVectorReader<bm::Encoder, decltype(instructions)>>(
110  bm::list, bm::data, logAvgSkip, iters);
111  });
112  return iters;
113 }
std::vector< uint32_t > data
auto dispatchInstructions(F &&f) -> decltype(f(std::declval< instructions::Default >()))
Encoder::MutableCompressedList list
size_t SkipTo_SkipQ128 ( size_t  iters,
size_t  logAvgSkip 
)

Definition at line 132 of file BitVectorCodingTest.cpp.

References BENCHMARK_NAMED_PARAM_MULTI, bm::data, folly::compression::dispatchInstructions(), and bm::list.

Referenced by BENCHMARK().

132  {
133  dispatchInstructions([&](auto instructions) {
134  bmSkipTo<BitVectorReader<bm::Encoder, decltype(instructions)>>(
135  bm::list, bm::data, logAvgSkip, iters);
136  });
137  return iters;
138 }
std::vector< uint32_t > data
auto dispatchInstructions(F &&f) -> decltype(f(std::declval< instructions::Default >()))
Encoder::MutableCompressedList list
TEST_F ( BitVectorCodingTest  ,
Empty   
)

Definition at line 48 of file BitVectorCodingTest.cpp.

48  {
49  doTestEmpty();
50 }
TEST_F ( BitVectorCodingTest  ,
Simple   
)

Definition at line 52 of file BitVectorCodingTest.cpp.

52  {
53  doTestAll<0, 0>();
54 }
TEST_F ( BitVectorCodingTest  ,
SkipPointers   
)

Definition at line 56 of file BitVectorCodingTest.cpp.

56  {
57  doTestAll<128, 0>();
58 }
TEST_F ( BitVectorCodingTest  ,
ForwardPointers   
)

Definition at line 60 of file BitVectorCodingTest.cpp.

60  {
61  doTestAll<0, 128>();
62 }
TEST_F ( BitVectorCodingTest  ,
SkipForwardPointers   
)

Definition at line 64 of file BitVectorCodingTest.cpp.

64  {
65  doTestAll<128, 128>();
66 }