Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 33s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 22s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 36s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 25s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 55s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 44s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m2s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 51s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 37s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 23s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 40s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 56s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 45s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m1s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 53s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 28s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 22s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 45s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 42s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 42s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 38s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 46s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 43s
Bigfoot / Clang Format Checks (push) Successful in 10s
188 lines
5.3 KiB
C++
188 lines
5.3 KiB
C++
/*********************************************************************
|
|
* \file Reference.cpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date August 2026
|
|
*********************************************************************/
|
|
#include <Engine/Asset/Reference.hpp>
|
|
|
|
#include <Engine/Asset/AssetLibrary.hpp>
|
|
|
|
#include <AssetsForBenchmarking/Asset/BenchmarkAsset.hpp>
|
|
|
|
#include <EASTL/optional.h>
|
|
#include <EASTL/vector.h>
|
|
#include <benchmark/benchmark.h>
|
|
|
|
#include <cstddef>
|
|
#include <utility>
|
|
|
|
namespace Bigfoot
|
|
{
|
|
template<template<class> class REFERENCE>
|
|
class ReferenceFixture: public benchmark::Fixture
|
|
{
|
|
protected:
|
|
using ReferenceType = REFERENCE<BenchmarkAsset>;
|
|
|
|
void SetUp(benchmark::State&) override
|
|
{
|
|
SetActiveAssetLibrary(&m_library);
|
|
std::ignore = m_library.Insert(&m_container);
|
|
|
|
m_uuid = m_container.Insert()->GetAsset()->GetHeader().uuid;
|
|
m_reference.emplace(m_uuid);
|
|
}
|
|
|
|
void TearDown(benchmark::State&) override
|
|
{
|
|
SetActiveAssetLibrary(&g_assetLibrary);
|
|
}
|
|
|
|
AssetLibrary m_library;
|
|
AssetContainer<BenchmarkAsset> m_container;
|
|
UUID m_uuid;
|
|
eastl::optional<ReferenceType> m_reference;
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, HardReferenceConstruct, HardReference)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
ReferenceType reference {m_uuid};
|
|
benchmark::DoNotOptimize(reference);
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, HardReferenceConstruct)->Name("Reference/HardReference/Construct");
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, SoftReferenceConstruct, SoftReference)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
ReferenceType reference {m_uuid};
|
|
benchmark::DoNotOptimize(reference);
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, SoftReferenceConstruct)->Name("Reference/SoftReference/Construct");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, HardReferenceGet, HardReference)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
benchmark::DoNotOptimize(m_reference->Get());
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, HardReferenceGet)->Name("Reference/HardReference/Get");
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, SoftReferenceGet, SoftReference)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
benchmark::DoNotOptimize(m_reference->Get());
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, SoftReferenceGet)->Name("Reference/SoftReference/Get");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, HardReferenceCopy, HardReference)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
ReferenceType copy {*m_reference};
|
|
benchmark::DoNotOptimize(copy);
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, HardReferenceCopy)->Name("Reference/HardReference/Copy");
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, SoftReferenceCopy, SoftReference)(benchmark::State& state)
|
|
{
|
|
for (auto _: state)
|
|
{
|
|
ReferenceType copy {*m_reference};
|
|
benchmark::DoNotOptimize(copy);
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations());
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, SoftReferenceCopy)->Name("Reference/SoftReference/Copy");
|
|
|
|
/****************************************************************************************/
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, HardReferenceMove, HardReference)(benchmark::State& state)
|
|
{
|
|
constexpr std::size_t BATCH_SIZE = 128;
|
|
eastl::vector<ReferenceType> batch;
|
|
batch.reserve(BATCH_SIZE);
|
|
|
|
for (auto _: state)
|
|
{
|
|
state.PauseTiming();
|
|
batch.clear();
|
|
for (std::size_t i = 0; i < BATCH_SIZE; ++i)
|
|
{
|
|
batch.emplace_back(m_uuid);
|
|
}
|
|
state.ResumeTiming();
|
|
|
|
for (ReferenceType& reference: batch)
|
|
{
|
|
ReferenceType moved {std::move(reference)};
|
|
benchmark::DoNotOptimize(moved);
|
|
}
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations() * BATCH_SIZE);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, HardReferenceMove)->Name("Reference/HardReference/Move");
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(ReferenceFixture, SoftReferenceMove, SoftReference)(benchmark::State& state)
|
|
{
|
|
constexpr std::size_t BATCH_SIZE = 128;
|
|
eastl::vector<ReferenceType> batch;
|
|
batch.reserve(BATCH_SIZE);
|
|
|
|
for (auto _: state)
|
|
{
|
|
state.PauseTiming();
|
|
batch.clear();
|
|
for (std::size_t i = 0; i < BATCH_SIZE; ++i)
|
|
{
|
|
batch.emplace_back(m_uuid);
|
|
}
|
|
state.ResumeTiming();
|
|
|
|
for (ReferenceType& reference: batch)
|
|
{
|
|
ReferenceType moved {std::move(reference)};
|
|
benchmark::DoNotOptimize(moved);
|
|
}
|
|
}
|
|
|
|
state.SetItemsProcessed(state.iterations() * BATCH_SIZE);
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(ReferenceFixture, SoftReferenceMove)->Name("Reference/SoftReference/Move");
|
|
} // namespace Bigfoot
|