#include #include #include constexpr unsigned mcd1(unsigned a, unsigned b) { while (a != b) if (a > b) a -= b; else b -= a; return a; } constexpr unsigned mcd2(unsigned a, unsigned b) { if (b == 0) return a; else return mcd2(b, a % b); } static_assert(mcd1(48, 60) == mcd2(48, 60), "mcd1(48, 60) != mcd2(48, 60)!!!"); template static void test(benchmark::State &state) { std::mt19937_64 generator(0); std::uniform_int_distribution distribution; auto rng = [&]() { return distribution(generator); }; for (auto _: state) benchmark::DoNotOptimize(f(rng(), rng())); } BENCHMARK(test)->Iterations(1'000'000); BENCHMARK(test)->Iterations(1'000'000); BENCHMARK_MAIN();