diff --git a/src/tests/benchmarks/benchmark_preamble.cc b/src/tests/benchmarks/benchmark_preamble.cc index c004b6e30..cb0b54c3c 100644 --- a/src/tests/benchmarks/benchmark_preamble.cc +++ b/src/tests/benchmarks/benchmark_preamble.cc @@ -25,13 +25,14 @@ void bm_forloop(benchmark::State& state) { - std::array d_preamble_samples{}; + std::array d_preamble_samples{}; + volatile int32_t res; // Prevent the compiler from optimizing the loop away while (state.KeepRunning()) { int32_t n = 0; - for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) + for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) { - if (GPS_CA_PREAMBLE[i] == '1') + if (GPS_CA_PREAMBLE_SYMBOLS_STR[i] == '1') { d_preamble_samples[n] = 1; n++; @@ -42,16 +43,27 @@ void bm_forloop(benchmark::State& state) n++; } } + res = d_preamble_samples[GPS_CA_PREAMBLE_LENGTH_SYMBOLS - 1]; + } + if (res > 1) + { + // Avoid unused-but-set-variable warning } } void bm_generate(benchmark::State& state) { - std::array d_preamble_samples{}; + std::array d_preamble_samples{}; + volatile int32_t res; // Prevent the compiler from optimizing the loop away while (state.KeepRunning()) { - std::generate(d_preamble_samples.begin(), d_preamble_samples.end(), [n = 0]() mutable { return (GPS_CA_PREAMBLE[n++] == '1' ? 1 : -1); }); + std::generate(d_preamble_samples.begin(), d_preamble_samples.end(), [n = 0]() mutable { return (GPS_CA_PREAMBLE_SYMBOLS_STR[n++] == '1' ? 1 : -1); }); + res = d_preamble_samples[GPS_CA_PREAMBLE_LENGTH_SYMBOLS - 1]; + } + if (res > 1) + { + // Avoid unused-but-set-variable warning } }