BigFile/Sasquatch #1
@@ -2,3 +2,6 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/AssetsForBenchmarking)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Engine)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Utils)
|
||||
if(${TOOLMODE})
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Tools)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/SasquatchBaker)
|
||||
@@ -0,0 +1,13 @@
|
||||
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
project(${PackageName}Benchmarks)
|
||||
|
||||
bigfoot_create_package_benchmarks(
|
||||
"Tools")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<LINK_LIBRARY:WHOLE_ARCHIVE,AssetsForBenchmarking>)
|
||||
|
||||
bigfoot_create_bigfile("Benchmarks/Tools")
|
||||
|
||||
bigfoot_create_sasquatch_info()
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// AUTO-GENERATED DO NOT TOUCH
|
||||
|
||||
/*********************************************************************
|
||||
* \file BigFileInfo.generated.hpp
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_SASQUATCHBAKERBENCHMARKS_BIGFILEINFO_GENERATED_HPP
|
||||
#define BIGFOOT_SASQUATCHBAKERBENCHMARKS_BIGFILEINFO_GENERATED_HPP
|
||||
|
||||
#include <EASTL/string_view.h>
|
||||
|
||||
#if defined BIGFOOT_TOOLMODE
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
/*
|
||||
* BigFile location
|
||||
*/
|
||||
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-bigfile.db"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// AUTO-GENERATED DO NOT TOUCH
|
||||
|
||||
/*********************************************************************
|
||||
* \file SasquatchInfo.generated.hpp
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_SASQUATCHBAKERBENCHMARKS_SASQUATCHINFO_GENERATED_HPP
|
||||
#define BIGFOOT_SASQUATCHBAKERBENCHMARKS_SASQUATCHINFO_GENERATED_HPP
|
||||
|
||||
#include <EASTL/string_view.h>
|
||||
|
||||
#if defined BIGFOOT_GAME
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
/*
|
||||
* Sasquatch location
|
||||
*/
|
||||
constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-sasquatch.sasquatch"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
/*********************************************************************
|
||||
* \file SasquatchBaker.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date August 2026
|
||||
*********************************************************************/
|
||||
#include <SasquatchBaker/SasquatchBaker.hpp>
|
||||
|
||||
#include <Engine/BigFile/BigFile.hpp>
|
||||
#include <Engine/Sasquatch/Sasquatch.hpp>
|
||||
|
||||
#include <System/File/File.hpp>
|
||||
|
||||
#include <SasquatchBakerBenchmarks/BigFileInfo_generated.hpp>
|
||||
|
||||
#include <AssetsForBenchmarking/Asset/BenchmarkAsset.hpp>
|
||||
|
||||
#include <EASTL/vector.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
// SasquatchInfo_generated.hpp only exposes SASQUATCH_..._LOCATION in BIGFOOT_GAME builds, but this
|
||||
// benchmark needs it to bake into a Sasquatch file from toolmode. Fake the macro locally rather than
|
||||
// widening the shared template.
|
||||
#define BIGFOOT_GAME
|
||||
#include <SasquatchBakerBenchmarks/SasquatchInfo_generated.hpp>
|
||||
#undef BIGFOOT_GAME
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
class SasquatchBakerFixture: public benchmark::Fixture
|
||||
{
|
||||
protected:
|
||||
static constexpr std::uint32_t ASSET_COUNT = 20'000;
|
||||
static constexpr std::size_t ASSET_PAYLOAD_SIZE = 256;
|
||||
|
||||
void SetUp(benchmark::State&) override
|
||||
{
|
||||
BigFile::Request {m_bigFile, "DELETE FROM Asset;"}.Execute();
|
||||
BigFile::Request {m_bigFile, "DELETE FROM AssetMetadata;"}.Execute();
|
||||
m_sasquatch.Delete();
|
||||
|
||||
eastl::vector<AssetMetadata> metadatas;
|
||||
eastl::vector<eastl::vector<std::byte>> flatbuffers;
|
||||
metadatas.reserve(ASSET_COUNT);
|
||||
flatbuffers.reserve(ASSET_COUNT);
|
||||
|
||||
for (std::uint32_t i = 0; i < ASSET_COUNT; ++i)
|
||||
{
|
||||
BenchmarkAsset asset;
|
||||
asset.SetName(asset.GetHeader().uuid.ToString().c_str());
|
||||
asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB});
|
||||
|
||||
metadatas.push_back(AssetMetadata {.m_uuid = asset.GetHeader().uuid,
|
||||
.m_name = asset.GetHeader().name,
|
||||
.m_typeID = asset.GetHeader().type_id,
|
||||
.m_typeName = asset.GetHeader().type_name});
|
||||
flatbuffers.push_back(asset.Pack());
|
||||
}
|
||||
|
||||
m_bigFile.SaveAssetFlatbuffers(metadatas, flatbuffers);
|
||||
}
|
||||
|
||||
void TearDown(benchmark::State&) override
|
||||
{
|
||||
m_sasquatch.Delete();
|
||||
}
|
||||
|
||||
BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION}};
|
||||
File m_sasquatch {SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION};
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
BENCHMARK_DEFINE_F(SasquatchBakerFixture, Bake)(benchmark::State& state)
|
||||
{
|
||||
std::int64_t bytesProcessed = 0;
|
||||
|
||||
for (auto _: state)
|
||||
{
|
||||
Bake(m_bigFile, m_sasquatch);
|
||||
bytesProcessed += static_cast<std::int64_t>(m_sasquatch.GetSize());
|
||||
}
|
||||
|
||||
state.SetItemsProcessed(state.iterations() * ASSET_COUNT);
|
||||
state.SetBytesProcessed(bytesProcessed);
|
||||
}
|
||||
|
||||
BENCHMARK_REGISTER_F(SasquatchBakerFixture, Bake)->Name("SasquatchBaker/Bake")->Unit(benchmark::kMillisecond);
|
||||
} // namespace Bigfoot
|
||||
Reference in New Issue
Block a user