MCPcopy Create free account
hub / github.com/darktable-org/rawspeed / BM_BitStream

Function BM_BitStream

bench/librawspeed/io/BitStreamBenchmark.cpp:47–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46template <typename Pump>
47static inline void BM_BitStream(benchmark::State& state, Endianness endianness,
48 unsigned int fillSize, unsigned int Step) {
49 assert(state.range(0) > 0);
50 assert((size_t)state.range(0) <=
51 std::numeric_limits<rawspeed::Buffer::size_type>::max());
52
53 assert(fillSize > 0);
54 assert(fillSize <= STEP_MAX);
55
56 assert(Step > 0);
57 assert(Step <= STEP_MAX);
58
59 assert(Step <= fillSize);
60
61 assert((Step == 1) || rawspeed::isAligned(Step, 2));
62 assert((fillSize == 1) || rawspeed::isAligned(fillSize, 2));
63
64 auto storage = rawspeed::Buffer::Create(state.range(0));
65 const rawspeed::Buffer b(storage.get(), state.range(0));
66 assert(b.getSize() > 0);
67 assert(b.getSize() == (size_t)state.range(0));
68
69 const rawspeed::DataBuffer db(b, endianness);
70 const rawspeed::ByteStream bs(db);
71
72 size_t processedBits = 0;
73 for (auto _ : state) {
74 Pump pump(bs);
75
76 for (processedBits = 0; processedBits <= 8 * b.getSize();) {
77 pump.fill(fillSize);
78
79 // NOTE: you may want to change the callee here
80 for (auto i = 0U; i < fillSize; i += Step)
81 pump.skipBitsNoFill(Step);
82
83 processedBits += fillSize;
84 }
85 }
86
87 assert(processedBits > fillSize);
88 processedBits -= fillSize;
89
90 assert(rawspeed::roundUp(8 * b.getSize(), fillSize) == processedBits);
91
92 state.SetComplexityN(processedBits / 8);
93 state.SetItemsProcessed(processedBits * state.iterations());
94 state.SetBytesProcessed(state.items_processed() / 8);
95}
96
97static inline void CustomArguments(benchmark::internal::Benchmark* b) {
98 b->RangeMultiplier(2);

Callers

nothing calls this directly

Calls 6

isAlignedFunction · 0.85
roundUpFunction · 0.85
fillMethod · 0.80
skipBitsNoFillMethod · 0.80
getMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected