#include "diol.h" #include "diol.hpp" using namespace diol; void foo(Bencher bencher, PlotArg arg) { auto v = std::vector(arg.n); std::move(bencher).bench([&] { for (auto &x : v) { x *= 2.0; } }); } void bar(Bencher bencher, PlotArg arg) { auto v = std::vector(arg.n); std::move(bencher).bench([&] { for (auto &x : v) { x *= 0.1; } }); } void foo_tup(Bencher bencher, Tuple arg) { auto [m, n] = arg; auto v = std::vector(n); std::move(bencher).bench([&] { for (auto &x : v) { x *= 2.0; } }); } void bar_tup(Bencher bencher, Tuple arg) { auto [m, n] = arg; auto v = std::vector(n); std::move(bencher).bench([&] { for (auto &x : v) { x *= 0.1; } }); } int main() { auto config = BenchConfig::from_args(); config.set_metric("f64/s", HigherIsBetter, [](std::uintptr_t n, double time) { return n / time; }); auto bench = Bench::from_config(config); { Function funcs[] = {{"foo", foo}, {"bar", bar}}; PlotArg args[] = {1, 2, 4, 512}; bench.register_funcs(funcs, args); } { Function> funcs[] = {{"foo", foo_tup}, {"bar", bar_tup}}; Tuple args[] = {{{1, 2}}, {{2, 4}}, {{4, 6}}, {{512, 768}}}; bench.register_funcs>(funcs, args); } bench.run(); }