55#include " benchmarks/cpp/flatbuffers/fb_bench.h"
66#include " benchmarks/cpp/raw/raw_bench.h"
77
8- static inline void Encode (benchmark::State & state,
9- std::unique_ptr<Bench> & bench, uint8_t * buffer) {
8+ static inline void Encode (benchmark::State& state,
9+ std::unique_ptr<Bench>& bench, uint8_t * buffer) {
1010 int64_t length;
1111 for (auto _ : state) {
1212 bench->Encode (buffer, length);
1313 benchmark::DoNotOptimize (length);
1414 }
1515}
1616
17- static inline void Decode (benchmark::State & state,
18- std::unique_ptr<Bench> & bench, uint8_t * buffer) {
17+ static inline void Decode (benchmark::State& state,
18+ std::unique_ptr<Bench>& bench, uint8_t * buffer) {
1919 int64_t length;
20- uint8_t * encoded = bench->Encode (buffer, length);
20+ uint8_t * encoded = bench->Encode (buffer, length);
2121
2222 for (auto _ : state) {
23- void * decoded = bench->Decode (encoded, length);
23+ void * decoded = bench->Decode (encoded, length);
2424 benchmark::DoNotOptimize (decoded);
2525 }
2626}
2727
28- static inline void Use (benchmark::State & state, std::unique_ptr<Bench> & bench,
29- uint8_t * buffer, int64_t check_sum) {
28+ static inline void Use (benchmark::State& state, std::unique_ptr<Bench>& bench,
29+ uint8_t * buffer, int64_t check_sum) {
3030 int64_t length;
31- uint8_t * encoded = bench->Encode (buffer, length);
32- void * decoded = bench->Decode (encoded, length);
31+ uint8_t * encoded = bench->Encode (buffer, length);
32+ void * decoded = bench->Decode (encoded, length);
3333
3434 int64_t sum = 0 ;
3535
36- for (auto _ : state) { sum = bench->Use (decoded); }
36+ for (auto _ : state) {
37+ sum = bench->Use (decoded);
38+ }
3739
3840 EXPECT_EQ (sum, check_sum);
3941}
4042
41- static void BM_Flatbuffers_Encode (benchmark::State & state) {
43+ static void BM_Flatbuffers_Encode (benchmark::State& state) {
4244 const int64_t kBufferLength = 1024 ;
4345 uint8_t buffer[kBufferLength ];
4446
@@ -48,7 +50,7 @@ static void BM_Flatbuffers_Encode(benchmark::State &state) {
4850}
4951BENCHMARK (BM_Flatbuffers_Encode);
5052
51- static void BM_Flatbuffers_Decode (benchmark::State & state) {
53+ static void BM_Flatbuffers_Decode (benchmark::State& state) {
5254 const int64_t kBufferLength = 1024 ;
5355 uint8_t buffer[kBufferLength ];
5456
@@ -58,7 +60,7 @@ static void BM_Flatbuffers_Decode(benchmark::State &state) {
5860}
5961BENCHMARK (BM_Flatbuffers_Decode);
6062
61- static void BM_Flatbuffers_Use (benchmark::State & state) {
63+ static void BM_Flatbuffers_Use (benchmark::State& state) {
6264 const int64_t kBufferLength = 1024 ;
6365 uint8_t buffer[kBufferLength ];
6466
@@ -68,7 +70,7 @@ static void BM_Flatbuffers_Use(benchmark::State &state) {
6870}
6971BENCHMARK (BM_Flatbuffers_Use);
7072
71- static void BM_Raw_Encode (benchmark::State & state) {
73+ static void BM_Raw_Encode (benchmark::State& state) {
7274 const int64_t kBufferLength = 1024 ;
7375 uint8_t buffer[kBufferLength ];
7476
@@ -77,7 +79,7 @@ static void BM_Raw_Encode(benchmark::State &state) {
7779}
7880BENCHMARK (BM_Raw_Encode);
7981
80- static void BM_Raw_Decode (benchmark::State & state) {
82+ static void BM_Raw_Decode (benchmark::State& state) {
8183 const int64_t kBufferLength = 1024 ;
8284 uint8_t buffer[kBufferLength ];
8385
@@ -86,7 +88,7 @@ static void BM_Raw_Decode(benchmark::State &state) {
8688}
8789BENCHMARK (BM_Raw_Decode);
8890
89- static void BM_Raw_Use (benchmark::State & state) {
91+ static void BM_Raw_Use (benchmark::State& state) {
9092 const int64_t kBufferLength = 1024 ;
9193 uint8_t buffer[kBufferLength ];
9294
0 commit comments