Play-/Source/ui_shared/StatsManager.h

52 lines
932 B
C
Raw Normal View History

2016-08-23 00:54:10 +01:00
#pragma once
#include <mutex>
#include <map>
#include "Types.h"
#include "Singleton.h"
#include "Profiler.h"
#include "../PS2VM.h"
2016-08-23 00:54:10 +01:00
class CStatsManager : public CSingleton<CStatsManager>
{
public:
void OnNewFrame(CPS2VM*, uint32);
static float ComputeCpuUsageRatio(int32 idleTicks, int32 totalTicks);
2018-04-30 21:01:23 +01:00
uint32 GetFrames();
uint32 GetDrawCalls();
CPS2VM::CPU_UTILISATION_INFO GetCpuUtilisationInfo();
2016-08-23 00:54:10 +01:00
#ifdef PROFILE
2018-04-30 21:01:23 +01:00
std::string GetProfilingInfo();
2016-08-23 00:54:10 +01:00
#endif
2018-04-30 21:01:23 +01:00
void ClearStats();
2016-08-23 00:54:10 +01:00
#ifdef PROFILE
void OnProfileFrameDone(const CProfiler::ZoneArray&);
2016-08-23 00:54:10 +01:00
#endif
2018-04-30 21:01:23 +01:00
2016-08-23 00:54:10 +01:00
private:
2018-04-30 21:01:23 +01:00
std::mutex m_statsMutex;
uint32 m_frames = 0;
uint32 m_drawCalls = 0;
CPS2VM::CPU_UTILISATION_INFO m_cpuUtilisation;
2016-08-23 00:54:10 +01:00
#ifdef PROFILE
struct ZONEINFO
{
uint64 currentValue = 0;
uint64 minValue = ~0ULL;
uint64 maxValue = 0;
};
typedef std::map<std::string, ZONEINFO> ZoneMap;
2018-04-30 21:01:23 +01:00
std::mutex m_profilerZonesMutex;
ZoneMap m_profilerZones;
2016-08-23 00:54:10 +01:00
#endif
};