chromium/base/big_endian_perftest.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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

// Register the benchmarks as a GTest test. This allows using legacy
// --gtest_filter and --gtest_list_tests.
// TODO(https://crbug.com/40251982): Clean this up after transitioning to
// --benchmark_filter and --benchmark_list_tests.
TEST(BigEndianPerfTest, All) {}

#undef BENCHMARK_FOR_INT_TYPES

}  // namespace
}  // namespace base