/********************************************************************* * \file SasquatchBaker.cpp * * \author Romain BOULLARD * \date August 2026 *********************************************************************/ #include #include #include #include #include #include #include #include #include #include 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 { m_bigFile.Clear(); m_outputFile.Delete(); eastl::vector uuids; eastl::vector> flatbuffers; eastl::vector> hardReferences; uuids.reserve(ASSET_COUNT); flatbuffers.reserve(ASSET_COUNT); hardReferences.reserve(ASSET_COUNT); for (std::uint32_t i = 0; i < ASSET_COUNT; ++i) { BenchmarkAsset asset; asset.SetName(asset.GetHeader().uuid.ToString()); asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); const eastl::vector flatbuffer = asset.Pack(); flatbuffers.push_back(flatbuffer); hardReferences.push_back(asset.GetHardReferences(flatbuffer)); uuids.push_back(asset.GetHeader().uuid); } m_bigFile.SaveAssetFlatbuffers(uuids, flatbuffers, hardReferences); } void TearDown(benchmark::State&) override { m_outputFile.Delete(); } static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION { "./SasquatchBakerBenchmarks.sasquatch"}; BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION}}; File m_outputFile {SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION}; }; /****************************************************************************************/ BENCHMARK_DEFINE_F(SasquatchBakerFixture, Bake)(benchmark::State& state) { std::int64_t bytesProcessed = 0; for (auto _: state) { Bake(m_bigFile, m_outputFile); bytesProcessed += static_cast(m_outputFile.GetSize()); } state.SetItemsProcessed(state.iterations() * ASSET_COUNT); state.SetBytesProcessed(bytesProcessed); } BENCHMARK_REGISTER_F(SasquatchBakerFixture, Bake)->Name("SasquatchBaker/Bake")->Unit(benchmark::kMillisecond); } // namespace Bigfoot