#include #include "crc32.h" #include #include #ifdef __aarch64__ # define ARMCRC32 #endif static void BM_CRC32(benchmark::State& state) { char* input = new char[state.range(0)]; for (auto _ : state) crc32((uint8_t*) input, state.range(0)); state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(state.range(0))); delete[] input; } #ifdef ARMCRC32 static void BM_CRC32_ARM(benchmark::State& state) { char* input = new char[state.range(0)]; for (auto _ : state) crc32_arm((uint8_t*) input, state.range(0)); state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(state.range(0))); delete[] input; } #endif BENCHMARK(BM_CRC32)->Arg(8)->Arg(64)->Arg(512)->Arg(4<<10)->Arg(8<<10)->Arg(16<<10)->Arg(32<<10)->Arg(64<<10); #ifdef ARMCRC32 BENCHMARK(BM_CRC32_ARM)->Arg(8)->Arg(64)->Arg(512)->Arg(4<<10)->Arg(8<<10)->Arg(16<<10)->Arg(32<<10)->Arg(64<<10); #endif BENCHMARK_MAIN();