mirror of
https://github.com/libretro/Play-.git
synced 2024-12-02 22:46:23 +00:00
a5aaa0bea0
git-svn-id: http://svn.purei.org/purei/trunk@1051 b36208d7-6611-0410-8bec-b1987f11c4a2
64 lines
1015 B
C++
64 lines
1015 B
C++
#ifndef _PROFILER_H_
|
|
#define _PROFILER_H_
|
|
|
|
#include <string>
|
|
#include <ctime>
|
|
#include <map>
|
|
#include <stack>
|
|
#include <thread>
|
|
#include "Singleton.h"
|
|
|
|
#ifdef PROFILE
|
|
|
|
#define PROFILE_OTHERZONE "Other"
|
|
|
|
class CProfiler : public CSingleton<CProfiler>
|
|
{
|
|
public:
|
|
typedef std::map<std::string, clock_t> ZoneMap;
|
|
|
|
friend CSingleton;
|
|
|
|
void BeginIteration();
|
|
void EndIteration();
|
|
|
|
void BeginZone(const char*);
|
|
void EndZone();
|
|
|
|
ZoneMap GetStats();
|
|
void Reset();
|
|
|
|
void SetWorkThread();
|
|
|
|
private:
|
|
typedef std::stack<std::string> ZoneStack;
|
|
|
|
CProfiler();
|
|
virtual ~CProfiler();
|
|
|
|
void AddTimeToCurrentZone(clock_t);
|
|
|
|
std::mutex m_mutex;
|
|
clock_t m_currentTime;
|
|
ZoneMap m_zones;
|
|
ZoneStack m_zoneStack;
|
|
|
|
#ifdef _DEBUG
|
|
std::thread::id m_workThreadId;
|
|
#endif
|
|
};
|
|
|
|
class CProfilerZone
|
|
{
|
|
public:
|
|
CProfilerZone(const char*);
|
|
~CProfilerZone();
|
|
|
|
private:
|
|
const char* m_name;
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif
|