diff --git a/Bigfoot/Benchmarks/Engine/BigFile/BigFile.cpp b/Bigfoot/Benchmarks/Engine/BigFile/BigFile.cpp index 80db522..326b50d 100644 --- a/Bigfoot/Benchmarks/Engine/BigFile/BigFile.cpp +++ b/Bigfoot/Benchmarks/Engine/BigFile/BigFile.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -30,40 +31,23 @@ class BigFileFixture: public benchmark::Fixture { protected: static constexpr std::uint32_t ASSET_COUNT = 20'000; + static constexpr std::uint32_t REFS_PER_ASSET = 4; static constexpr std::size_t ASSET_PAYLOAD_SIZE = 256; void SetUp(benchmark::State&) override { - m_bigFile.Clear(); + // The DB is populated exactly once for the entire benchmark process. + // SetUp is called before every calibration round (Google Benchmark doubles + // iteration counts until it reaches a stable measurement), so rebuilding + // the DB each time would dominate the total benchmark time. + static const eastl::vector s_uuids = BuildData(); + m_uuids = &s_uuids; + m_bigFile.emplace(File {BIGFILE_ENGINEBENCHMARKS_LOCATION}); + } - m_uuids.clear(); - m_uuids.reserve(ASSET_COUNT); - - eastl::vector> flatbuffers; - eastl::vector> hardReferences; - 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().c_str()); - asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); - for (std::uint32_t j = 0; j < 4; ++j) - { - BenchmarkAssetReferred assetReferred; - assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str()); - - asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid); - } - - const eastl::vector flatbuffer = asset.Pack(); - flatbuffers.push_back(flatbuffer); - hardReferences.push_back(asset.GetHardReferences(flatbuffer)); - m_uuids.push_back(asset.GetHeader().uuid); - } - - m_bigFile.SaveAssetFlatbuffers(m_uuids, flatbuffers, hardReferences); + void TearDown(benchmark::State&) override + { + m_bigFile.reset(); } [[nodiscard]] @@ -73,7 +57,7 @@ class BigFileFixture: public benchmark::Fixture batch.reserve(p_batchSize); for (std::size_t i = 0; i < p_batchSize; ++i) { - batch.push_back(m_uuids[Random::get(0, m_uuids.size() - 1)]); + batch.push_back((*m_uuids)[Random::get(0, m_uuids->size() - 1)]); } return batch; @@ -93,8 +77,44 @@ class BigFileFixture: public benchmark::Fixture return pool; } - BigFile m_bigFile {File {BIGFILE_ENGINEBENCHMARKS_LOCATION}}; - eastl::vector m_uuids; + eastl::optional m_bigFile; + const eastl::vector* m_uuids = nullptr; + + private: + static eastl::vector BuildData() + { + 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().c_str()); + asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); + for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j) + { + BenchmarkAssetReferred assetReferred; + assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str()); + + asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid); + } + + eastl::vector flatbuffer = asset.Pack(); + hardReferences.push_back(asset.GetHardReferences(flatbuffer)); + flatbuffers.push_back(std::move(flatbuffer)); + uuids.push_back(asset.GetHeader().uuid); + } + + BigFile bigFile {File {BIGFILE_ENGINEBENCHMARKS_LOCATION}}; + bigFile.Clear(); + bigFile.SaveAssetFlatbuffers(uuids, flatbuffers, hardReferences); + + return uuids; + } }; /****************************************************************************************/ @@ -105,8 +125,8 @@ BENCHMARK_DEFINE_F(BigFileFixture, GetAssetFlatbuffer)(benchmark::State& state) for (auto _: state) { - eastl::vector flatbuffer = m_bigFile.GetAssetFlatbuffer( - m_uuids[Random::get(0, m_uuids.size() - 1)]); + eastl::vector flatbuffer = m_bigFile->GetAssetFlatbuffer( + (*m_uuids)[Random::get(0, m_uuids->size() - 1)]); benchmark::DoNotOptimize(flatbuffer); bytesProcessed += static_cast(flatbuffer.size()); @@ -132,7 +152,7 @@ BENCHMARK_DEFINE_F(BigFileFixture, GetAssetFlatbuffers)(benchmark::State& state) for (auto _: state) { - eastl::vector> flatbuffers = m_bigFile.GetAssetFlatbuffers(batchPool[batchIndex]); + eastl::vector> flatbuffers = m_bigFile->GetAssetFlatbuffers(batchPool[batchIndex]); benchmark::DoNotOptimize(flatbuffers); for (const eastl::vector& flatbuffer: flatbuffers) @@ -163,7 +183,7 @@ BENCHMARK_DEFINE_F(BigFileFixture, GetAssetHardReferences)(benchmark::State& sta for (auto _: state) { benchmark::DoNotOptimize( - m_bigFile.GetAssetHardReferences(m_uuids[Random::get(0, m_uuids.size() - 1)])); + m_bigFile->GetAssetHardReferences((*m_uuids)[Random::get(0, m_uuids->size() - 1)])); } state.SetItemsProcessed(state.iterations()); @@ -183,7 +203,7 @@ BENCHMARK_DEFINE_F(BigFileFixture, GetAssetsHardReferences)(benchmark::State& st std::size_t batchIndex = 0; for (auto _: state) { - benchmark::DoNotOptimize(m_bigFile.GetAssetsHardReferences(batchPool[batchIndex])); + benchmark::DoNotOptimize(m_bigFile->GetAssetsHardReferences(batchPool[batchIndex])); batchIndex = (batchIndex + 1) % BATCH_POOL_SIZE; } @@ -217,7 +237,7 @@ BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffer)(benchmark::State& state) bytesProcessed += static_cast(flatbuffer.size()); state.ResumeTiming(); - m_bigFile.SaveAssetFlatbuffer(asset.GetHeader().uuid, flatbuffer, hardReferences); + m_bigFile->SaveAssetFlatbuffer(asset.GetHeader().uuid, flatbuffer, hardReferences); } state.SetItemsProcessed(state.iterations()); @@ -236,8 +256,10 @@ BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffers)(benchmark::State& state for (auto _: state) { state.PauseTiming(); + eastl::vector uuids; eastl::vector> flatbuffers; eastl::vector> hardReferences; + uuids.reserve(batchSize); flatbuffers.reserve(batchSize); hardReferences.reserve(batchSize); @@ -247,14 +269,15 @@ BENCHMARK_DEFINE_F(BigFileFixture, SaveAssetFlatbuffers)(benchmark::State& state asset.SetName(asset.GetHeader().uuid.ToString().c_str()); 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)); + eastl::vector flatbuffer = asset.Pack(); + uuids.push_back(asset.GetHeader().uuid); bytesProcessed += static_cast(flatbuffer.size()); + hardReferences.push_back(asset.GetHardReferences(flatbuffer)); + flatbuffers.push_back(std::move(flatbuffer)); } state.ResumeTiming(); - m_bigFile.SaveAssetFlatbuffers(m_uuids, flatbuffers, hardReferences); + m_bigFile->SaveAssetFlatbuffers(uuids, flatbuffers, hardReferences); } state.SetItemsProcessed(state.iterations() * batchSize); diff --git a/Bigfoot/Benchmarks/Engine/Sasquatch/Sasquatch.cpp b/Bigfoot/Benchmarks/Engine/Sasquatch/Sasquatch.cpp index 994af0f..5ae2dcb 100644 --- a/Bigfoot/Benchmarks/Engine/Sasquatch/Sasquatch.cpp +++ b/Bigfoot/Benchmarks/Engine/Sasquatch/Sasquatch.cpp @@ -30,75 +30,18 @@ using Random = effolkronium::random_static; class SasquatchFixture: public benchmark::Fixture { protected: - struct SasquatchData - { - UUID m_uuid; - eastl::span m_flatbuffer; - eastl::span m_hardReferences; - }; - static constexpr std::uint32_t ASSET_COUNT = 20'000; + static constexpr std::uint32_t REFS_PER_ASSET = 4; static constexpr std::size_t ASSET_PAYLOAD_SIZE = 256; void SetUp([[maybe_unused]] benchmark::State& p_state) override { - File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}.Delete(); - - eastl::vector> flatbuffers; - eastl::vector> hardReferences; - flatbuffers.reserve(ASSET_COUNT); - hardReferences.reserve(ASSET_COUNT); - - m_uuids.clear(); - m_uuids.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}); - for (std::uint32_t j = 0; j < 4; ++j) - { - BenchmarkAssetReferred assetReferred; - assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str()); - - asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid); - } - - const eastl::vector flatbuffer = asset.Pack(); - flatbuffers.push_back(flatbuffer); - hardReferences.push_back(asset.GetHardReferences(flatbuffer)); - m_uuids.push_back(asset.GetHeader().uuid); - } - - eastl::vector assets; - assets.reserve(ASSET_COUNT); - for (std::uint32_t i = 0; i < ASSET_COUNT; ++i) - { - assets.push_back(SasquatchData {.m_uuid = m_uuids[i], - .m_flatbuffer = flatbuffers[i], - .m_hardReferences = hardReferences[i]}); - } - - std::size_t totalFlatbufferBytes = 0; - std::size_t totalHardReferencesBytes = 0; - for (const SasquatchData& asset: assets) - { - totalFlatbufferBytes += asset.m_flatbuffer.size(); - totalHardReferencesBytes += asset.m_hardReferences.size() * UUID::UUID_BYTE_SIZE; - } - - { - SasquatchWriter writer {File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}, - assets.size(), - totalFlatbufferBytes, - totalHardReferencesBytes}; - for (const SasquatchData& asset: assets) - { - writer.WriteAsset(asset.m_uuid, asset.m_flatbuffer, asset.m_hardReferences); - } - } - + // The Sasquatch file is built exactly once for the entire benchmark process. + // SetUp is called before every calibration round (Google Benchmark doubles + // iteration counts until it reaches a stable measurement), so rebuilding + // the file each time would dominate the total benchmark time. + static const eastl::vector s_uuids = BuildData(); + m_uuids = &s_uuids; m_sasquatch.emplace(File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}); } @@ -114,7 +57,7 @@ class SasquatchFixture: public benchmark::Fixture batch.reserve(p_batchSize); for (std::size_t i = 0; i < p_batchSize; ++i) { - batch.push_back(m_uuids[Random::get(0, m_uuids.size() - 1)]); + batch.push_back((*m_uuids)[Random::get(0, m_uuids->size() - 1)]); } return batch; @@ -135,7 +78,58 @@ class SasquatchFixture: public benchmark::Fixture } eastl::optional m_sasquatch; - eastl::vector m_uuids; + const eastl::vector* m_uuids = nullptr; + + private: + static eastl::vector BuildData() + { + File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}.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().c_str()); + asset.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); + for (std::uint32_t j = 0; j < REFS_PER_ASSET; ++j) + { + BenchmarkAssetReferred assetReferred; + assetReferred.SetName(assetReferred.GetHeader().uuid.ToString().c_str()); + + asset.GetAsset().refs.emplace_back(assetReferred.GetHeader().uuid); + } + + eastl::vector flatbuffer = asset.Pack(); + hardReferences.push_back(asset.GetHardReferences(flatbuffer)); + flatbuffers.push_back(std::move(flatbuffer)); + uuids.push_back(asset.GetHeader().uuid); + } + + std::size_t totalFlatbufferBytes = 0; + std::size_t totalHardReferencesBytes = 0; + for (std::size_t i = 0; i < uuids.size(); ++i) + { + totalFlatbufferBytes += flatbuffers[i].size(); + totalHardReferencesBytes += hardReferences[i].size() * UUID::UUID_BYTE_SIZE; + } + + SasquatchWriter writer {File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}, + uuids.size(), + totalFlatbufferBytes, + totalHardReferencesBytes}; + for (std::size_t i = 0; i < uuids.size(); ++i) + { + writer.WriteAsset(uuids[i], flatbuffers[i], hardReferences[i]); + } + + return uuids; + } }; /****************************************************************************************/ @@ -145,7 +139,7 @@ BENCHMARK_DEFINE_F(SasquatchFixture, GetAssetHardReferences)(benchmark::State& s for (auto _: state) { benchmark::DoNotOptimize( - m_sasquatch->GetAssetHardReferences(m_uuids[Random::get(0, m_uuids.size() - 1)])); + m_sasquatch->GetAssetHardReferences((*m_uuids)[Random::get(0, m_uuids->size() - 1)])); } state.SetItemsProcessed(state.iterations()); @@ -190,7 +184,7 @@ BENCHMARK_DEFINE_F(SasquatchFixture, GetAssetFlatbuffer)(benchmark::State& state for (auto _: state) { eastl::vector flatbuffer = m_sasquatch->GetAssetFlatbuffer( - m_uuids[Random::get(0, m_uuids.size() - 1)]); + (*m_uuids)[Random::get(0, m_uuids->size() - 1)]); benchmark::DoNotOptimize(flatbuffer); bytesProcessed += static_cast(flatbuffer.size()); diff --git a/Bigfoot/Benchmarks/Engine/SerializationManager/SerializationManager.cpp b/Bigfoot/Benchmarks/Engine/SerializationManager/SerializationManager.cpp index 1509e70..52f6997 100644 --- a/Bigfoot/Benchmarks/Engine/SerializationManager/SerializationManager.cpp +++ b/Bigfoot/Benchmarks/Engine/SerializationManager/SerializationManager.cpp @@ -51,79 +51,19 @@ class SerializationManagerFixture: public benchmark::Fixture m_previousDataAccessor = g_dataAccessor; m_previousAssetLibrary = g_activeAssetLibrary; - m_rootUuids.clear(); - m_rootUuids.reserve(ROOT_ASSET_COUNT); - m_leafUuids.clear(); - m_leafUuids.reserve(ROOT_ASSET_COUNT * REFS_PER_ROOT); - - eastl::vector uuids; - eastl::vector> flatbuffers; - eastl::vector> hardReferences; - uuids.reserve(ROOT_ASSET_COUNT * (1 + REFS_PER_ROOT)); - flatbuffers.reserve(uuids.capacity()); - hardReferences.reserve(uuids.capacity()); - - m_rootTotalBytes.clear(); - m_rootTotalBytes.reserve(ROOT_ASSET_COUNT); - - for (std::uint32_t i = 0; i < ROOT_ASSET_COUNT; ++i) - { - BenchmarkAsset root; - root.SetName(root.GetHeader().uuid.ToString().c_str()); - root.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); - - std::size_t totalBytes = 0; - for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j) - { - BenchmarkAssetReferred leaf; - leaf.SetName(leaf.GetHeader().uuid.ToString().c_str()); - - root.GetAsset().refs.emplace_back(leaf.GetHeader().uuid); - - const eastl::vector leafFlatbuffer = leaf.Pack(); - totalBytes += leafFlatbuffer.size(); - m_leafUuids.push_back(leaf.GetHeader().uuid); - uuids.push_back(leaf.GetHeader().uuid); - hardReferences.push_back(leaf.GetHardReferences(leafFlatbuffer)); - flatbuffers.push_back(leafFlatbuffer); - } - - const eastl::vector rootFlatbuffer = root.Pack(); - totalBytes += rootFlatbuffer.size(); - m_rootTotalBytes.emplace(root.GetHeader().uuid, totalBytes); - m_rootUuids.push_back(root.GetHeader().uuid); - uuids.push_back(root.GetHeader().uuid); - hardReferences.push_back(root.GetHardReferences(rootFlatbuffer)); - flatbuffers.push_back(rootFlatbuffer); - } + // The data store is populated exactly once for the entire benchmark process. + // SetUp is called before every calibration round (Google Benchmark doubles + // iteration counts until it reaches a stable measurement), so rebuilding + // the data store each time would dominate the total benchmark time. + static const SharedData& s_data = BuildData(); + m_rootUuids = &s_data.rootUuids; + m_leafUuids = &s_data.leafUuids; + m_rootTotalBytes = &s_data.rootTotalBytes; #if defined BIGFOOT_TOOLMODE m_bigFile.emplace(File {BIGFILE_ENGINEBENCHMARKS_LOCATION}); - m_bigFile->Clear(); - m_bigFile->SaveAssetFlatbuffers(uuids, flatbuffers, hardReferences); - SetDataAccessor(&*m_bigFile); #elif defined BIGFOOT_GAME - std::size_t totalFlatbufferBytes = 0; - std::size_t totalHardReferencesBytes = 0; - for (std::size_t i = 0; i < uuids.size(); ++i) - { - totalFlatbufferBytes += flatbuffers[i].size(); - totalHardReferencesBytes += hardReferences[i].size() * UUID::UUID_BYTE_SIZE; - } - - File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}.Delete(); - { - SasquatchWriter writer {File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}, - uuids.size(), - totalFlatbufferBytes, - totalHardReferencesBytes}; - for (std::size_t i = 0; i < uuids.size(); ++i) - { - writer.WriteAsset(uuids[i], flatbuffers[i], hardReferences[i]); - } - } - m_sasquatch.emplace(File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}); SetDataAccessor(&*m_sasquatch); #endif @@ -163,7 +103,7 @@ class SerializationManagerFixture: public benchmark::Fixture batch.reserve(p_batchSize); for (std::size_t i = 0; i < p_batchSize; ++i) { - batch.push_back(m_rootUuids[Random::get(0, m_rootUuids.size() - 1)]); + batch.push_back((*m_rootUuids)[Random::get(0, m_rootUuids->size() - 1)]); } return batch; @@ -189,7 +129,7 @@ class SerializationManagerFixture: public benchmark::Fixture std::int64_t bytes = 0; for (const UUID& uuid: unique) { - bytes += static_cast(m_rootTotalBytes.at(uuid)); + bytes += static_cast(m_rootTotalBytes->at(uuid)); } return bytes; @@ -198,15 +138,100 @@ class SerializationManagerFixture: public benchmark::Fixture DataAccessor* m_previousDataAccessor = nullptr; AssetLibrary* m_previousAssetLibrary = nullptr; - eastl::vector m_rootUuids; - eastl::vector m_leafUuids; - ankerl::unordered_dense::map m_rootTotalBytes; + const eastl::vector* m_rootUuids = nullptr; + const eastl::vector* m_leafUuids = nullptr; + const ankerl::unordered_dense::map* m_rootTotalBytes = nullptr; #if defined BIGFOOT_TOOLMODE eastl::optional m_bigFile; #elif defined BIGFOOT_GAME eastl::optional m_sasquatch; #endif + + private: + struct SharedData + { + eastl::vector rootUuids; + eastl::vector leafUuids; + ankerl::unordered_dense::map rootTotalBytes; + }; + + static const SharedData& BuildData() + { + static const SharedData s_data = []() + { + SharedData data; + data.rootUuids.reserve(ROOT_ASSET_COUNT); + data.leafUuids.reserve(ROOT_ASSET_COUNT * REFS_PER_ROOT); + data.rootTotalBytes.reserve(ROOT_ASSET_COUNT); + + eastl::vector uuids; + eastl::vector> flatbuffers; + eastl::vector> hardReferences; + uuids.reserve(ROOT_ASSET_COUNT * (1 + REFS_PER_ROOT)); + flatbuffers.reserve(uuids.capacity()); + hardReferences.reserve(uuids.capacity()); + + for (std::uint32_t i = 0; i < ROOT_ASSET_COUNT; ++i) + { + BenchmarkAsset root; + root.SetName(root.GetHeader().uuid.ToString().c_str()); + root.GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); + + std::size_t totalBytes = 0; + for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j) + { + BenchmarkAssetReferred leaf; + leaf.SetName(leaf.GetHeader().uuid.ToString().c_str()); + + root.GetAsset().refs.emplace_back(leaf.GetHeader().uuid); + + eastl::vector leafFlatbuffer = leaf.Pack(); + totalBytes += leafFlatbuffer.size(); + data.leafUuids.push_back(leaf.GetHeader().uuid); + uuids.push_back(leaf.GetHeader().uuid); + hardReferences.push_back(leaf.GetHardReferences(leafFlatbuffer)); + flatbuffers.push_back(std::move(leafFlatbuffer)); + } + + eastl::vector rootFlatbuffer = root.Pack(); + totalBytes += rootFlatbuffer.size(); + data.rootTotalBytes.emplace(root.GetHeader().uuid, totalBytes); + data.rootUuids.push_back(root.GetHeader().uuid); + uuids.push_back(root.GetHeader().uuid); + hardReferences.push_back(root.GetHardReferences(rootFlatbuffer)); + flatbuffers.push_back(std::move(rootFlatbuffer)); + } + +#if defined BIGFOOT_TOOLMODE + BigFile bigFile {File {BIGFILE_ENGINEBENCHMARKS_LOCATION}}; + bigFile.Clear(); + bigFile.SaveAssetFlatbuffers(uuids, flatbuffers, hardReferences); +#elif defined BIGFOOT_GAME + std::size_t totalFlatbufferBytes = 0; + std::size_t totalHardReferencesBytes = 0; + for (std::size_t i = 0; i < uuids.size(); ++i) + { + totalFlatbufferBytes += flatbuffers[i].size(); + totalHardReferencesBytes += hardReferences[i].size() * UUID::UUID_BYTE_SIZE; + } + + File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}.Delete(); + SasquatchWriter writer {File {SASQUATCH_ENGINEBENCHMARKS_LOCATION}, + uuids.size(), + totalFlatbufferBytes, + totalHardReferencesBytes}; + for (std::size_t i = 0; i < uuids.size(); ++i) + { + writer.WriteAsset(uuids[i], flatbuffers[i], hardReferences[i]); + } +#endif + + return data; + }(); + + return s_data; + } }; /****************************************************************************************/ @@ -225,8 +250,8 @@ BENCHMARK_DEFINE_F(SerializationManagerFixture, LoadAsset)(benchmark::State& sta AssetContainer rootContainer; ResetActiveLibrary(library, leafContainer, rootContainer); - const UUID uuid = m_rootUuids[Random::get(0, m_rootUuids.size() - 1)]; - const std::size_t uuidBytes = m_rootTotalBytes.at(uuid); + const UUID uuid = (*m_rootUuids)[Random::get(0, m_rootUuids->size() - 1)]; + const std::size_t uuidBytes = m_rootTotalBytes->at(uuid); state.ResumeTiming(); SerializationManager::LoadAsset(uuid); @@ -273,6 +298,7 @@ BENCHMARK_REGISTER_F(SerializationManagerFixture, LoadAssets) ->Arg(8) ->Arg(64) ->Arg(512) + ->Arg(4096) ->UseRealTime(); /****************************************************************************************/ @@ -295,7 +321,7 @@ BENCHMARK_DEFINE_F(SerializationManagerFixture, SaveAsset)(benchmark::State& sta asset->GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j) { - asset->GetAsset().refs.emplace_back(m_leafUuids[Random::get(0, m_leafUuids.size() - 1)]); + asset->GetAsset().refs.emplace_back((*m_leafUuids)[Random::get(0, m_leafUuids->size() - 1)]); } const UUID uuid = asset->GetHeader().uuid; const std::size_t assetBytes = asset->Pack().size(); @@ -335,7 +361,11 @@ BENCHMARK_DEFINE_F(SerializationManagerFixture, SaveAssets)(benchmark::State& st auto* asset = static_cast(container.Insert()->GetAsset()); asset->SetName(asset->GetHeader().uuid.ToString().c_str()); asset->GetAsset().payload.assign(ASSET_PAYLOAD_SIZE, std::uint8_t {0xAB}); - asset->GetAsset().refs.emplace_back(m_leafUuids[Random::get(0, m_leafUuids.size() - 1)]); + for (std::uint32_t j = 0; j < REFS_PER_ROOT; ++j) + { + asset->GetAsset().refs.emplace_back( + (*m_leafUuids)[Random::get(0, m_leafUuids->size() - 1)]); + } batchBytes += asset->Pack().size(); uuids.push_back(asset->GetHeader().uuid);