StatsCapture.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. // This is an AssetProcessor-only stats capture system. Its kept out-of-band
  9. // from the rest of the Asset Processor systems so that it can avoid interfering
  10. // with the rest of the processing decision making and other parts of AssetProcessor.
  11. // This is not meant to be used anywhere except in AssetProcessor.
  12. #pragma once
  13. #include <AzCore/std/optional.h>
  14. #include <AzCore/std/string/string_view.h>
  15. namespace AssetProcessor
  16. {
  17. namespace StatsCapture
  18. {
  19. //! call this one time before capturing stats.
  20. void Initialize();
  21. //! Call this one time as part of shutting down.
  22. void Shutdown();
  23. //! Start the clock running for a particular stat name.
  24. void BeginCaptureStat(AZStd::string_view statName);
  25. //! Stop the clock running for a particular stat name.
  26. //! Return this run's duration in milliseconds. If there is no such stat name,
  27. //! or if BeginCaptureStat was not called before, no duration is returned.
  28. AZStd::optional<AZStd::sys_time_t> EndCaptureStat(AZStd::string_view statName, bool persistToDb = false);
  29. //! Do additional processing and then write the cumulative stats to log.
  30. //! Note that since this is an AP-specific system, the analysis done in the dump function
  31. //! is going to make a lot of assumptions about the way the data is encoded.
  32. void Dump();
  33. }
  34. }