40template <
typename T>
void BM(benchmark::State& state,
bool Stuffed) {
41 int64_t numBytes = state.range(0);
43 assert(numBytes <= std::numeric_limits<int>::max());
49 genStuffed.
emplace(numBytes,
true);
50 numBytes = genStuffed->numBytesGenerated;
51 input = genStuffed->getInput();
54 numBytes = genUnstuffed->numBytesGenerated;
55 input = genUnstuffed->getInput();
57 benchmark::DoNotOptimize(input->begin());
59 for (
auto _ : state) {
62 constexpr int MaxGetBits = 32;
63 int processedBytes = 0;
64 for (processedBytes = 0; processedBytes != numBytes;
65 processedBytes += MaxGetBits / 8) {
66 uint32_t bits = bs.getBits(MaxGetBits);
67 benchmark::DoNotOptimize(bits);
72 state.SetComplexityN(numBytes);
73 state.counters.insert({
75 benchmark::Counter(
sizeof(uint8_t) * state.complexity_length_n(),
76 benchmark::Counter::Flags::kIsIterationInvariantRate,
77 benchmark::Counter::kIs1024)},
79 benchmark::Counter(
sizeof(uint8_t) * state.complexity_length_n(),
80 benchmark::Counter::Flags::kIsIterationInvariantRate |
81 benchmark::Counter::Flags::kInvert,
82 benchmark::Counter::kIs1000)},
87 b->Unit(benchmark::kMicrosecond);
88 b->RangeMultiplier(2);
90 static constexpr int L1dByteSize = 32U * (1U << 10U);
91 static constexpr int L2dByteSize = 512U * (1U << 10U);
92 static constexpr int MaxBytesOptimal = L2dByteSize * (1U << 5);
99 if constexpr ((
true)) {
100 b->Arg(MaxBytesOptimal);
102 b->Range(8, MaxBytesOptimal * (1U << 2));
103 b->Complexity(benchmark::oN);