36#include <benchmark/benchmark.h>
43using rawspeed::DeflateDecompressor;
47template <
size_t N>
using BPS = std::integral_constant<size_t, N>;
48template <
int N>
using Pf = std::integral_constant<int, N>;
50template <
typename BPS>
53 static_assert(BPS::value > 0,
"bad bps");
56 const uLong uncompressedLength = BPS::value * mRaw->
dim.
x * mRaw->
dim.
y / 8UL;
57 assert(uncompressedLength > 0);
58 assert(uncompressedLength <= std::numeric_limits<Buffer::size_type>::max());
60 *bufSize = compressBound(uncompressedLength);
62 assert(*bufSize <= std::numeric_limits<Buffer::size_type>::max());
64 const std::vector<uint8_t> uBuf(uncompressedLength);
65 std::vector<uint8_t> cBuf(*bufSize);
68 compress(cBuf.data(), bufSize, uBuf.data(), uncompressedLength);
72 assert(compressBound(uncompressedLength) >= *bufSize);
77template <
typename BPS,
typename Pf>
79 static_assert(BPS::value > 0,
"bad bps");
104 __builtin_unreachable();
109 std::unique_ptr<unsigned char[]> uBuffer;
111 for (
auto _ : state) {
112 DeflateDecompressor d(buf, mRaw, predictor, BPS::value);
114 d.decode(&uBuffer, mRaw->dim, mRaw->dim, {0, 0});
117 state.SetComplexityN(
dim.area());
118 state.SetItemsProcessed(state.complexity_length_n() * state.iterations());
119 state.SetBytesProcessed(BPS::value * state.items_processed() / 8);
124 static constexpr int L2dByteSize = 512U * (1U << 10U);
125 b->Arg((L2dByteSize / (32 / 8)) / 4);
129 b->RangeMultiplier(2);
131 if constexpr ((
true)) {
134 b->Range(1, 1023 << 20)->Complexity(benchmark::oN);
136 b->Unit(benchmark::kMillisecond);
140 BENCHMARK_TEMPLATE(BM_DeflateDecompressor, BPS<s>, Pf<f>)->Apply(CustomArgs);
141#define GEN_PFS(s) GEN_E(s, 1) GEN_E(s, 2) GEN_E(s, 4)
142#define GEN_PSS() GEN_PFS(16) GEN_PFS(24) GEN_PFS(32)
iPoint2D dim(rawspeed::implicit_cast< int >(ceil(sqSide *sqARatio)), rawspeed::implicit_cast< int >(ceil(sqSide/sqARatio)))
assert(dim.area() >=area)
bool RAWSPEED_READNONE benchmarkDryRun()
rawspeed::iPoint2D RAWSPEED_READNONE areaToRectangle(uint64_t area, rawspeed::iPoint2D aspect={2, 2})
size_type RAWSPEED_READONLY getSize() const
static RawImage create(RawImageType type=RawImageType::UINT16)
std::integral_constant< int, N > Pf
void BM_DeflateDecompressor(benchmark::State &state)
std::integral_constant< size_t, N > BPS
void CustomArgs(benchmark::internal::Benchmark *b)
std::vector< uint8_t > compressChunk(const rawspeed::RawImage &mRaw, uLong *bufSize)
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
constexpr RAWSPEED_READNONE bool isAligned(T value, size_t multiple)