Eliminate benchmark deprecation warnings
Resolve the following warnings issue by the latest version of the
benchmark library:
/Users/runner/work/ceres-solver/ceres-solver/internal/ceres/small_blas_gemv_benchmark.cc:71:54: warning: 'Benchmark' is deprecated: Use ::benchmark::Benchmark instead [-Wdeprecated-declarations]
71 | static void MatrixSizeArguments(benchmark::internal::Benchmark* benchmark) {
|
/Users/runner/work/ceres-solver/ceres-solver/internal/ceres/dense_linear_solver_benchmark.cc:67:46: warning: 'Benchmark' is deprecated: Use ::benchmark::Benchmark instead [-Wdeprecated-declarations]
67 | static void MatrixSizes(benchmark::internal::Benchmark* b) {
|
/Users/runner/work/ceres-solver/ceres-solver/internal/ceres/invert_psd_matrix_benchmark.cc:80:37: warning: 'Benchmark' is deprecated: Use ::benchmark::Benchmark instead [-Wdeprecated-declarations]
80 | ->Apply([](benchmark::internal::Benchmark* benchmark) {
|
Change-Id: Ice6fe57dc5635698809e368fda23a018f4d7df5a
diff --git a/internal/ceres/dense_linear_solver_benchmark.cc b/internal/ceres/dense_linear_solver_benchmark.cc
index 0930b7b..a2987cf 100644
--- a/internal/ceres/dense_linear_solver_benchmark.cc
+++ b/internal/ceres/dense_linear_solver_benchmark.cc
@@ -1,5 +1,5 @@
// Ceres Solver - A fast non-linear least squares minimizer
-// Copyright 2023 Google Inc. All rights reserved.
+// Copyright 2026 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@
}
// Some reasonable matrix sizes. I picked them out of thin air.
-static void MatrixSizes(benchmark::internal::Benchmark* b) {
+const auto MatrixSizes = [](auto* b) {
// {num_rows, num_cols}
b->Args({1, 1});
b->Args({2, 1});
@@ -82,7 +82,7 @@
b->Args({400, 20});
b->Args({600, 22});
b->Args({800, 25});
-}
+};
BENCHMARK_TEMPLATE2(BM_DenseSolver, ceres::EIGEN, ceres::DENSE_QR)
->Apply(MatrixSizes);
diff --git a/internal/ceres/invert_psd_matrix_benchmark.cc b/internal/ceres/invert_psd_matrix_benchmark.cc
index 16c3671..a2be4f7 100644
--- a/internal/ceres/invert_psd_matrix_benchmark.cc
+++ b/internal/ceres/invert_psd_matrix_benchmark.cc
@@ -1,5 +1,5 @@
// Ceres Solver - A fast non-linear least squares minimizer
-// Copyright 2023 Google Inc. All rights reserved.
+// Copyright 2026 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
@@ -76,12 +76,11 @@
}
}
-BENCHMARK(BenchmarkDynamicallyInvertPSDMatrix)
- ->Apply([](benchmark::internal::Benchmark* benchmark) {
- for (int i = 1; i < 13; ++i) {
- benchmark->Args({i});
- }
- });
+BENCHMARK(BenchmarkDynamicallyInvertPSDMatrix)->Apply([](auto* benchmark) {
+ for (int i = 1; i < 13; ++i) {
+ benchmark->Args({i});
+ }
+});
} // namespace ceres::internal
diff --git a/internal/ceres/small_blas_gemv_benchmark.cc b/internal/ceres/small_blas_gemv_benchmark.cc
index 6bf584d..c434554 100644
--- a/internal/ceres/small_blas_gemv_benchmark.cc
+++ b/internal/ceres/small_blas_gemv_benchmark.cc
@@ -1,5 +1,5 @@
// Ceres Solver - A fast non-linear least squares minimizer
-// Copyright 2023 Google Inc. All rights reserved.
+// Copyright 2026 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@
// Helper function to generate the various matrix sizes for which we
// run the benchmark.
-static void MatrixSizeArguments(benchmark::internal::Benchmark* benchmark) {
+const auto MatrixSizeArguments = [](auto* benchmark) {
std::vector<int> rows = {1, 2, 3, 4, 6, 8};
std::vector<int> cols = {1, 2, 3, 4, 8, 12, 15};
for (int r : rows) {
@@ -76,9 +76,10 @@
benchmark->Args({r, c});
}
}
-}
+};
-static void BM_MatrixVectorMultiply(benchmark::State& state) {
+static void
+BM_MatrixVectorMultiply(benchmark::State & state) {
const int rows = state.range(0);
const int cols = state.range(1);
MatrixVectorMultiplyData data(rows, cols);