142 for (
auto _ : state) {
146 decoder->failOnUnknown =
false;
149 decoder->decodeRaw();
153 benchmark::DoNotOptimize(raw);
159 const double CPUTime = TT().count();
160 const double WallTime = WT().count();
163 state.counters.insert({
165 benchmark::Counter(CPUTime, benchmark::Counter::Flags::kAvgIterations)},
167 benchmark::Counter(WallTime, benchmark::Counter::Flags::kAvgIterations)},
168 {
"CPUTime/WallTime", CPUTime / WallTime},
171 benchmark::Counter(pixels / CPUTime,
172 benchmark::Counter::Flags::kIsIterationInvariant)},
174 benchmark::Counter(pixels / WallTime,
175 benchmark::Counter::Flags::kIsIterationInvariant)},
178 benchmark::Counter(1.0 / CPUTime,
179 benchmark::Counter::Flags::kIsIterationInvariant)},
181 benchmark::Counter(1.0 / WallTime,
182 benchmark::Counter::Flags::kIsIterationInvariant)},
189 tName += std::to_string(threads);
191 auto* b = benchmark::RegisterBenchmark(tName, &
BM_RawSpeed, entry, threads);
192 b->Unit(benchmark::kMillisecond);
194 b->MeasureProcessCPUTime();
199int main(
int argc_,
char** argv_) {
200 benchmark::MaybeReenterWithoutASLR(argc_, argv_);
201 benchmark::Initialize(&argc_, argv_);
205 auto hasFlag = [argv](std::string_view flag) {
207 for (
int i = 1; i < argv.size(); ++i) {
208 if (!argv(i) || argv(i) != flag)
216 bool threading = hasFlag(
"-t");
219 const auto threadsMax = omp_get_max_threads();
221 const auto threadsMax = 1;
224 const auto threadsMin = threading ? 1 : threadsMax;
227 int useChecksumFile = hasFlag(
"-r");
228 std::vector<Entry> Worklist;
229 if (useChecksumFile && useChecksumFile + 1 < argv.size()) {
230 char*& checksumFileRepo = argv(useChecksumFile + 1);
231 if (checksumFileRepo) {
233 Worklist.reserve(readEntries.size());
236 Entry.Name = entryName;
237 Worklist.emplace_back(std::move(Entry));
240 checksumFileRepo =
nullptr;
244 for (
int i = 1; i < argv.size(); i++) {
249 const char* fName = argv(i);
252 Entry.Name.FullFileName = fName;
253 Entry.Name.RelFileName = fName;
254 Worklist.emplace_back(std::move(Entry));
258 for (Entry& entry : Worklist) {
259 std::string tName(entry.Name.RelFileName);
260 tName +=
"/threads:";
262 for (
auto threads = threadsMin; threads <= threadsMax; threads++)
266 benchmark::RunSpecifiedBenchmarks();
static const rawspeed::CameraMetaData metadata
void addBench(Entry *entry, std::string tName, int threads)
void BM_RawSpeed(benchmark::State &state, Entry *entry, int threads)
int RAWSPEED_READONLY rawspeed_get_number_of_processor_cores()
std::chrono::duration< rep, period > duration
static time_point now() noexcept
std::chrono::time_point< CPUClock, duration > time_point
std::ratio< 1, CLOCKS_PER_SEC > period
ChooseSteadyClock<>::type type
std::chrono::steady_clock type
std::chrono::high_resolution_clock type
rawspeed::ChecksumFileEntry Name
std::unique_ptr< std::vector< uint8_t, rawspeed::DefaultInitAllocatorAdaptor< uint8_t, rawspeed::AlignedAllocator< uint8_t, 16 > > > > Storage
const rawspeed::Buffer & getFileContents()
std::chrono::duration< rep, period > duration
duration operator()() const