From ee2efe938a9c171b776c950907de7db065010e73 Mon Sep 17 00:00:00 2001 From: kai Date: Tue, 6 May 2025 13:27:42 +0200 Subject: [PATCH] add benchmark --- lab07/gaus_seidel/gaus_seidel.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lab07/gaus_seidel/gaus_seidel.cpp b/lab07/gaus_seidel/gaus_seidel.cpp index 4de0978..72b4f81 100644 --- a/lab07/gaus_seidel/gaus_seidel.cpp +++ b/lab07/gaus_seidel/gaus_seidel.cpp @@ -96,15 +96,28 @@ void print_matrix(const Matrix &matrix) { } } -void benchmarkgaus_seidel(benchmark::State &state) { +void benchmarkComputeResult(benchmark::State &state) { + int iterations = state.range(0); Matrix matrix = Matrix(1000, 1000); + fill_matrix(matrix, 10); for (auto _ : state) { - gauss_seidel(matrix, 10000); + gauss_seidel(sec, iterations); benchmark::DoNotOptimize(matrix); } } -BENCHMARK(benchmarkgaus_seidel)->Unit(benchmark::kMillisecond); -BENCHMARK_MAIN(); +int main(int argc, char** argv)) { + ::benchmark::Initialize(&argc, argv); + + for (int iterations = 0; iterations < 10000; iterations++) { + benchmark::RegisterBenchmark("bench_gaus_seidel", benchmarkComputeResult) + ->Arg(iterations) + ->Unit(benchmark::kMillisecond); + } + + ::benchmark::RunSpecifiedBenchmarks(); + + return 0; +}