mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-19 05:33:02 +00:00
Benchmark with a longer string
This commit is contained in:
parent
b33d7ba739
commit
6cc96b039f
@ -25,13 +25,14 @@
|
|||||||
|
|
||||||
void bm_forloop(benchmark::State& state)
|
void bm_forloop(benchmark::State& state)
|
||||||
{
|
{
|
||||||
std::array<int32_t, GPS_CA_PREAMBLE_LENGTH_BITS> d_preamble_samples{};
|
std::array<int32_t, GPS_CA_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
|
||||||
|
volatile int32_t res; // Prevent the compiler from optimizing the loop away
|
||||||
while (state.KeepRunning())
|
while (state.KeepRunning())
|
||||||
{
|
{
|
||||||
int32_t n = 0;
|
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;
|
d_preamble_samples[n] = 1;
|
||||||
n++;
|
n++;
|
||||||
@ -42,16 +43,27 @@ void bm_forloop(benchmark::State& state)
|
|||||||
n++;
|
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)
|
void bm_generate(benchmark::State& state)
|
||||||
{
|
{
|
||||||
std::array<int32_t, GPS_CA_PREAMBLE_LENGTH_BITS> d_preamble_samples{};
|
std::array<int32_t, GPS_CA_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
|
||||||
|
volatile int32_t res; // Prevent the compiler from optimizing the loop away
|
||||||
while (state.KeepRunning())
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user