#include "base/big_endian.h"
#include <stdint.h>
#include "base/check.h"
#include "base/containers/span.h"
#include "base/numerics/byte_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/google_benchmark/src/include/benchmark/benchmark.h"
namespace base {
namespace {
constexpr size_t kSize = …;
int64_t aligned_bytes[kSize / sizeof(int64_t)];
struct { … } misaligned_bytes;
void DoNotOptimizeSpan(span<const uint8_t> range) { … }
template <typename T>
inline void WriteBigEndianCommon(::benchmark::State& state,
span<uint8_t, kSize> buffer) { … }
template <typename T>
void BM_WriteBigEndianAligned(::benchmark::State& state) { … }
template <typename T>
void BM_WriteBigEndianMisaligned(::benchmark::State& state) { … }
template <typename T>
inline void ReadBigEndianCommon(::benchmark::State& state,
span<const uint8_t, kSize> buffer) { … }
template <typename T>
void BM_ReadBigEndianAligned(::benchmark::State& state) { … }
template <typename T>
void BM_ReadBigEndianMisaligned(::benchmark::State& state) { … }
#define BENCHMARK_FOR_INT_TYPES …
TEST(BigEndianPerfTest, All) { … }
#undef BENCHMARK_FOR_INT_TYPES
}
}