#include #include #include constexpr unsigned mcd1(unsigned a, unsigned b) { while (a != b) if (a > b) a -= b; else b -= a; return a; } static_assert(mcd1(48, 18) == 6, "Inconsistent mcd1() implementation"); constexpr unsigned mcd2(unsigned a, unsigned b) { if (b == 0) return a; else return mcd2(b, a % b); } static_assert(mcd2(48, 18) == 6, "Inconsistent mcd2() implementation"); 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); BENCHMARK(test); BENCHMARK_MAIN();