PrefabLoadBenchmarks.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #if defined(HAVE_BENCHMARK)
  9. #include <Prefab/Benchmark/PrefabBenchmarkFixture.h>
  10. namespace Benchmark
  11. {
  12. using BM_PrefabLoad = BM_Prefab;
  13. using namespace AzToolsFramework::Prefab;
  14. BENCHMARK_DEFINE_F(BM_PrefabLoad, LoadPrefab_Basic)(::benchmark::State& state)
  15. {
  16. const unsigned int numTemplates = static_cast<unsigned int>(state.range());
  17. CreateFakePaths(numTemplates);
  18. for ([[maybe_unused]] auto _ : state)
  19. {
  20. state.PauseTiming();
  21. SetUpMockValidatorForReadPrefab();
  22. m_prefabLoaderInterface = AZ::Interface<PrefabLoaderInterface>::Get();
  23. state.ResumeTiming();
  24. for (unsigned int templateCounter = 0; templateCounter < numTemplates; ++templateCounter)
  25. {
  26. m_prefabLoaderInterface->LoadTemplateFromFile(m_paths[templateCounter]);
  27. }
  28. state.PauseTiming();
  29. ResetPrefabSystem();
  30. state.ResumeTiming();
  31. }
  32. state.SetComplexityN(numTemplates);
  33. }
  34. BENCHMARK_REGISTER_F(BM_PrefabLoad, LoadPrefab_Basic)
  35. ->RangeMultiplier(10)
  36. ->Range(100, 1000)
  37. ->Unit(benchmark::kMillisecond)
  38. ->Complexity();
  39. }
  40. #endif