You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.5 KiB
C++
98 lines
3.5 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <ScriptCanvas/Execution/ExecutionBus.h>
|
|
#include <ScriptCanvas/Execution/ExecutionPerformanceTimer.h>
|
|
|
|
namespace ScriptCanvas
|
|
{
|
|
namespace Execution
|
|
{
|
|
class PerformanceTimer;
|
|
|
|
class PerformanceTracker
|
|
{
|
|
friend class PerformanceScopeExecution;
|
|
friend class PerformanceScopeInitialization;
|
|
friend class PerformanceScopeLatent;
|
|
|
|
public:
|
|
AZ_TYPE_INFO(PerformanceTracker, "{D40DFC8B-D4EA-4D6A-A0CA-3FDD00604553}");
|
|
AZ_CLASS_ALLOCATOR(PerformanceTracker, AZ::SystemAllocator, 0);
|
|
|
|
PerformanceTracker();
|
|
|
|
~PerformanceTracker();
|
|
|
|
void CalculateReports();
|
|
|
|
void ClearGlobalReport();
|
|
|
|
void ClearSnapshotReport();
|
|
|
|
void FinalizeReport(PerformanceKey key, const AZ::Data::AssetId& assetId);
|
|
|
|
PerformanceTrackingReport GetGlobalReport() const;
|
|
|
|
PerformanceTrackingReport GetGlobalReportByAsset(const AZ::Data::AssetId& assetId) const;
|
|
|
|
// Not thread safe
|
|
const PerformanceReport& GetGlobalReportFull() const;
|
|
|
|
PerformanceTrackingReport GetSnapshotReport() const;
|
|
|
|
PerformanceTrackingReport GetSnapshotReportByAsset(const AZ::Data::AssetId& assetId) const;
|
|
|
|
// Not thread safe
|
|
const PerformanceReport& GetSnapshotReportFull() const;
|
|
|
|
private:
|
|
static PerformanceTrackingReport* ModOrCreateReport(PerformanceReportByAsset& reports, AZ::Data::AssetId key);
|
|
static PerformanceTrackingReport GetReportByAsset(const PerformanceReportByAsset& report, AZ::Data::AssetId key);
|
|
|
|
PerformanceReport m_lastCapturedSnapshot;
|
|
PerformanceReport m_lastCapturedGlobal;
|
|
|
|
PerformanceReport m_snapshotReport;
|
|
PerformanceReport m_globalReport;
|
|
|
|
AZStd::recursive_mutex m_activeTimerMutex;
|
|
|
|
AZStd::unordered_map<PerformanceKey, PerformanceTimer*> m_activeTimers;
|
|
|
|
struct AssetTimer
|
|
{
|
|
AZ_TYPE_INFO(AssetTimer, "{80860A85-C6B7-4544-8C30-62C76C657427}");
|
|
AZ_CLASS_ALLOCATOR(AssetTimer, AZ::SystemAllocator, 0);
|
|
|
|
PerformanceTimer timer;
|
|
AZ::u32 assetActivationCount = 0;
|
|
};
|
|
|
|
AZStd::unordered_map<AZ::Data::AssetId, AssetTimer*> m_timersByAsset;
|
|
|
|
PerformanceTimer* CreateTimer(PerformanceKey key);
|
|
|
|
AssetTimer* GetOrCreateTimer(const AZ::Data::AssetId& key);
|
|
|
|
PerformanceTimer* GetOrCreateTimer(PerformanceKey key);
|
|
|
|
void ReportExecutionTime(PerformanceKey key, const AZ::Data::AssetId& assetId, AZStd::sys_time_t);
|
|
|
|
void ReportLatentTime(PerformanceKey key, const AZ::Data::AssetId& assetId, AZStd::sys_time_t);
|
|
|
|
void ReportInitializationTime(PerformanceKey key, const AZ::Data::AssetId& assetId, AZStd::sys_time_t);
|
|
};
|
|
}
|
|
}
|