1 #include <benchmark/benchmark_api.h>
2 #include <marnav/nmea/checksum.hpp>
6 // Baseline implementation.
7 static std::string
checksum_to_string__v0(uint8_t sum
)
10 snprintf(buf
, sizeof(buf
), "%02X", sum
);
15 static void Benchmark_nmea_checksum_to_string_v0(benchmark::State
& state
)
18 while (state
.KeepRunning()) {
19 result
= checksum_to_string__v0(state
.range_x());
20 benchmark::DoNotOptimize(result
);
24 BENCHMARK(Benchmark_nmea_checksum_to_string_v0
)->Range(0x00, 0xff);
26 static void Benchmark_nmea_checksum_to_string(benchmark::State
& state
)
29 while (state
.KeepRunning()) {
30 result
= marnav::nmea::checksum_to_string(state
.range_x());
31 benchmark::DoNotOptimize(result
);
35 BENCHMARK(Benchmark_nmea_checksum_to_string
)->Range(0x00, 0xff);